Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API地址硬编码 #60

Open
jesHrz opened this issue Oct 17, 2024 · 1 comment
Open

API地址硬编码 #60

jesHrz opened this issue Oct 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@jesHrz
Copy link

jesHrz commented Oct 17, 2024

web2的api地址有两处使用了硬编码

  1. UrlPrefix https://github.com/SDUOJ/sduoj-web2/blob/master/src/Config/constValue.ts#L3
  2. apiAddress https://github.com/SDUOJ/sduoj-web2/blob/master/src/Utils/API/apiAddress.ts#L11-L14

感觉可以这样改:

  1. 目测这两个变量是有相关性的,可以放在同一个文件里
  2. 生产环境可以留空,或者从配置文件中读取(记得最初版本是分别针对development和production各有一个配置文件,然后从对应文件中读,maybe)

但是,实践中全置空似乎会影响gateway的转发

@jesHrz jesHrz added the bug Something isn't working label Oct 17, 2024
@jesHrz
Copy link
Author

jesHrz commented Oct 19, 2024

Markdown组件依赖的静态资源应当直接使用apiAddress()返回的结果
https://github.com/SDUOJ/sduoj-web2/blob/master/src/Utils/MarkdownPreview.ts#L5-L7

如果考虑到分布式部署,静态资源存在某个cdn上,也应当将url集成进apiAddress(),但是这样可能需要考虑重新抽象apiAddres

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant