由于新版的React对多重跨域进行了代码更新所以在使用旧版的React多重跨域代码的时候会导致localhost连接错误
新版React将多重跨域代码修改为
const { createProxyMiddleware } = require('http-proxy-middleware')
module.exports = function(app){
app.use(
createProxyMiddleware('/api1',{ //遇见/api1前缀的请求,就会触发该代理配置
target:'http://localhost:5000', //请求转发给谁
changeOrigin:true,//控制服务器收到的请求头中Host的值
pathRewrite:{'^/api1':''} //重写请求路径(必须)
}),
)
}