react http-proxy-middleware 跨域处理
第一步安装依赖
yarn add 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, } )) }