const { createProxyMiddleware } = require('http-proxy-middleware'); const REACT_APP_NETWORK = process.env.REACT_APP_NETWORK; // const origin = 'https://safeliab-test.ccic-net.com.cn'; const origin = 'https://safeliab.ccic-net.com.cn'; const PROXY_REMOTE = { '/base': `${origin}/base`, '/service': `${origin}/service`, '/business': `${origin}/business`, }; const PROXY_LOCAL = { '/base': `http://10.3.0.33:8080/base`, '/service': `http://10.3.0.33:8080/service`, '/business': `http://10.3.0.33:8080/business`, }; const PROXY = REACT_APP_NETWORK === 'intranet' ? PROXY_LOCAL : PROXY_REMOTE; module.exports = function (app) { for (let api in PROXY) { if (Object.prototype.hasOwnProperty.call(PROXY, api)) { app.use( api, createProxyMiddleware({ target: PROXY[api], pathRewrite: { [`^${api}`]: '' }, changeOrigin: true, }), ); } } };