You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

37 lines
982 B

const { createProxyMiddleware } = require('http-proxy-middleware');
const REACT_APP_NETWORK = process.env.REACT_APP_NETWORK;
const origin = 'http://ccic.dev.jeean.cn'; //本地测试环境api
// 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;
const PROXY = 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,
}),
);
}
}
};