后台:处理proxy

This commit is contained in:
luying
2021-12-30 15:28:03 +08:00
parent 4e63b109ae
commit 6e881bc9c7
3 changed files with 32 additions and 13 deletions

View File

@@ -77,30 +77,32 @@ export default (appInfo: EggAppInfo) => {
};
let regions = [ // 大区数据
{ id: 1, env: 'stable', name: "常山少年", domain: 'http://zyz_gm.trgame.cn' },
{ id: 2, env: 'alpha', name: "测试服", domain: 'http://pinus_gm_test.trgame.cn' },
{ id: 3, env: 'dev', name: "开发服", domain: 'http://zyzdev_gm.trgame.cn' }
{ env: 'stable', name: "常山少年", domain: 'http://zyz_gm.trgame.cn' },
{ env: 'alpha', name: "测试服", domain: 'http://pinus_gm_test.trgame.cn' },
{ env: 'dev', name: "开发服", domain: 'http://zyzdev_gm.trgame.cn' },
// 37测试服组
{ env: 'sq1', name: "37测试1服", domain: 'http://39.103.207.209: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}`] = {
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')
console.log('proxy', path, path.replace(`/web/${env}/`, '/web/'))
return path.replace(`/web/${env}/`, '/web/')
}
}
}