【前端-架构管理】请求规范-Path #524
Unanswered
ly525
asked this question in
API 协议|规范|请求(库)
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
从后端服务迁移,思考前端请求层规范应该如何写?
比如请求
request('https://www.baidu.com/user-center-xxx/mini-app/auth')
request('https://www.baidu.com/user-center-yyy/mini-app/auth')
request('https://www.baidu.com/user-center-zzz/mini-app/auth')
1. host 不用写,配置 baseURL 即可,即
原因:
2. 请求path 需写完整,尽量减少拼接形式的,即
/user-center-xxx/mini-app/auth
这种形式的(没有host的完整path)3. 请求协议使用自适应协议即可
#228
4. host 相关变量,末尾请不要携带 /
具体可以参考
window.location.host
,因为/
是属于window.location.pathname
的Beta Was this translation helpful? Give feedback.
All reactions