const proxyMiddleWare= require('http-proxy-middleware');
app.use("/api",proxyMiddleWare({ target: “http://www.baidu.com”, changeOrigin: true, pathRewrite: function (path, req) { return path.replace('/api', '') } // pathRewrite: {'^/api' : '',}这种写法会有问题,有时候会携带api过去 }));