安装:
npm install --save-dev http-proxy-middleware
然后在项目 “src" 目录下新建文件 "setupProxy.js”
例如代理 “/app” 到 “http://localhost:8000”
const { createProxyMiddleware } = require('http-proxy-middleware')
module.exports = function(app) {
app.use(createProxyMiddleware('/app',
{
target: "http://localhost:8000",
changeOrigin:true,
pathRewrite: {
"^/app": "/"
}
}))
}