后台:处理proxy
This commit is contained in:
@@ -24,19 +24,28 @@ export default (appInfo: EggAppInfo) => {
|
||||
};
|
||||
|
||||
let regions = [ // 大区数据
|
||||
{ id: 1, env: 'dev', name: "测试", domain: 'http://127.0.0.1:7002' },
|
||||
{ id: 1, env: 'development', name: "测试", domain: 'http://127.0.0.1:7500' },
|
||||
];
|
||||
config.regions = regions;
|
||||
|
||||
let httpProxy: any = {};
|
||||
for(let { env, domain } of regions) {
|
||||
httpProxy[`/api/${env}`] = {
|
||||
httpProxy[`/api/${env}/`] = {
|
||||
target: domain,
|
||||
changeOrigin: true,
|
||||
secure: true,
|
||||
pathRewrite: function(path) {
|
||||
console.log('proxy', path, path.replace(`/api/${env}`, '/api'))
|
||||
return path.replace(`/api/${env}`, '/api')
|
||||
console.log('proxy', path, path.replace(`/api/${env}/`, '/api/'))
|
||||
return path.replace(`/api/${env}/`, '/api/')
|
||||
}
|
||||
}
|
||||
httpProxy[`/web/${env}/`] = {
|
||||
target: domain,
|
||||
changeOrigin: true,
|
||||
secure: true,
|
||||
pathRewrite: function(path) {
|
||||
console.log('proxy', path, path.replace(`/web/${env}/`, '/web/'))
|
||||
return path.replace(`/web/${env}/`, '/web/')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user