diff --git a/admin-web/config/server/config/proxy.prod.config.js b/admin-web/config/server/config/proxy.prod.config.js index a3ce7f6f4..14f7cc78e 100644 --- a/admin-web/config/server/config/proxy.prod.config.js +++ b/admin-web/config/server/config/proxy.prod.config.js @@ -1,9 +1,38 @@ +// production 配置文件 + module.exports = { - '/admin-api -> http://180.167.213.26:18083/': { + '/admin-api/': { + target: 'http://api.shop.iocoder.cn:18099/admin-api', changeOrigin: true, pathRewrite: {}, }, - '/server/api -> https://preview.pro.ant.design/': { + '/product-api/': { + target: 'http://api.shop.iocoder.cn:18099/product-api', + changeOrigin: true, + pathRewrite: {}, + }, + '/order-api/': { + target: 'http://api.shop.iocoder.cn:18099/order-api', + changeOrigin: true, + pathRewrite: {}, + }, + '/promotion-api/': { + target: 'http://api.shop.iocoder.cn:18099/promotion-api', + changeOrigin: true, + pathRewrite: {}, + }, + '/pay-api/': { + target: 'http://api.shop.iocoder.cn:18099/pay-api', + changeOrigin: true, + pathRewrite: {}, + }, + '/user-api/': { + target: 'http://api.shop.iocoder.cn:18099/user-api', + changeOrigin: true, + pathRewrite: {}, + }, + '/server/api/': { + target: 'https://preview.pro.ant.design/', changeOrigin: true, pathRewrite: { '^/server': '' }, }, diff --git a/admin-web/config/server/utils/proxy.build.js b/admin-web/config/server/utils/proxy.build.js index 781bb93a4..63f2e2e47 100644 --- a/admin-web/config/server/utils/proxy.build.js +++ b/admin-web/config/server/utils/proxy.build.js @@ -18,37 +18,32 @@ module.exports = function(config) { console.info(chalkSuccess('build proxy.%s.config 配置!'), process.env.NODE_ENV); const proxys = []; - if (!config) { console.log(chalkError('proxy.%s.config 没有配置!'), process.env.NODE_ENV); } for (const key in config) { + let source; + let target; if (/->/.test(key)) { const keys = key.toString().split('->'); - - let source; - let target; - if (keys.length <= 1) { - // 没有 -> - source = key; - target = config.target; - } else { - source = keys[0].trim(); - target = keys[1].trim(); - } - - if (typeof config !== 'object') { - console.log( - chalkError('%s: proxy.%s.config 初始化失败 config 类型为 object!'), - key, - process.env.NODE_ENV - ); - break; - } - - proxys.push(proxy(source, ObjectAssign({ target }, config[key]))); + source = keys[0].trim(); + target = keys[1].trim(); + } else { + source = key; + target = config[key].target; } + + if (typeof config !== 'object') { + console.log( + chalkError('%s: proxy.%s.config 初始化失败 config 类型为 object!'), + key, + process.env.NODE_ENV + ); + break; + } + + proxys.push(proxy(source, ObjectAssign({ target }, config[key]))); } return proxys;