配置
1.1 依赖
npm install http-proxy-middleware
1.2 新建文件
src 下目录新建 setupProxy.js
src > setupProcy.js
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function (app) {
app.use(createProxyMiddleware('api', {
target: "http://localhost:8080", //配置的地址
changeOrigin: true,
pathRewrite: {
"^/api": ""
}
}))
};
1.3 修改路径
修改 config 目录下 paths.js 文件
config > paths.js
proxySetup: resolveApp('src/setupProxy.js'),
网友评论