react 中配置 http-proxy-middleware
在src目录中创建 setupProxy.js文件
添加如下配置
const createProxyMiddleware = require('http-proxy-middleware')
module.exports = function (app) {
app.use(
createProxyMiddleware('/api', {
target: 'http://localhost:5000',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
})
)
}