首先我们需要安装http-proxy-middleware中间件
然后在src目录下创建setupProxy.js文件
里面填写代理规则即可
const proxy = require('http-proxy-middleware')
module.exports = function (app) {
app.use(proxy('/api',{
target: 'http://localhost:8083',
changeOrigin: true,
// pathRewrite: {
// "^/api": "/"
// }
}))
}
可以根据自己的需求更改
保存后此时并不能生效
要想生效必须重新启动npm