安装http-proxy-middleware:
yarn add http-proxy-middleware
在'src'目录下新建'setupProxy.js'并写入:
const proxy = require('http-proxy-middleware');
module.exports = function (app) {
app.use('/api', proxy({
target: ' http://172.16.30.166:8000',
pathRewrite: {
'^/api': ''
},
changeOrigin: true,
}));
};
重新启动服务
网友评论