refactor(api): 统一API路径配置并优化相关服务调用
All checks were successful
test/timeline-frontend/pipeline/head This commit looks good
All checks were successful
test/timeline-frontend/pipeline/head This commit looks good
feat: 添加API URL全局配置文件 fix: 修复SSR环境下的窗口对象检查 perf: 优化代理配置路径匹配顺序 style: 移除无用注释和未使用的类型声明
This commit is contained in:
@@ -15,13 +15,22 @@ export default {
|
||||
// 如果需要自定义本地开发服务器 请取消注释按需调整
|
||||
dev: {
|
||||
// localhost:8000/api/** -> https://preview.pro.ant.design/api/**
|
||||
// 注意:更具体的路径应该放在前面,避免被通用路径覆盖
|
||||
'/api/story/': {
|
||||
// 要代理的地址
|
||||
target: basePath,
|
||||
// 配置了这个可以从 http 代理到 https
|
||||
// 依赖 origin 的功能可能需要这个,比如 cookie
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '^/api/story': '/api/story' },
|
||||
pathRewrite: { '^/api/story': '/story' },
|
||||
},
|
||||
'/api/user/': {
|
||||
// 要代理的地址
|
||||
target: basePath,
|
||||
// 配置了这个可以从 http 代理到 https
|
||||
// 依赖 origin 的功能可能需要这个,比如 cookie
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '^/api/user': '/user' },
|
||||
},
|
||||
'/file/': {
|
||||
// 要代理的地址
|
||||
@@ -39,10 +48,11 @@ export default {
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '^/user-api': '/user' },
|
||||
},
|
||||
// 通用 /api/ 代理放在最后,避免覆盖上面的具体配置
|
||||
'/api/': {
|
||||
target: 'https://proapi.azurewebsites.net',
|
||||
target: basePath,
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '^': '' },
|
||||
pathRewrite: { '^/api': '/api' },
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user