vue|react vue前端请求后端 跨域访问样例

本机访问

const proxy = require("http-proxy-middleware"); module.exports = function (app) { app.use(proxy("/xxxx-base-manage", { target: "http://127.0.0.1:11020", changeOrigin: true, pathRewrite: { "^/xxxx-base-manage": "" } })); app.use(proxy("/xxxx-base-biz", { target: "http://127.0.0.1:10021", changeOrigin: true, pathRewrite: { "^/xxxx-base-biz": "" } })); app.use(proxy("/xxxx-info-manage", { target: "http://127.0.0.1:11011", changeOrigin: true, pathRewrite: { "^/xxxx-info-manage": "" } })); app.use(proxy("/xxxx-auth-center", { target: "http://127.0.0.1:10022", changeOrigin: true, pathRewrite: { "^/xxxx-auth-center": "" } })); };

服务器访问 去掉pathRewrite即可。
【vue|react vue前端请求后端 跨域访问样例】

    推荐阅读