本机访问
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前端请求后端 跨域访问样例】
推荐阅读
- JavaScript|vue 基于axios封装request接口请求——request.js文件
- 前端|web前端dya07--ES6高级语法的转化&render&vue与webpack&export
- 前端开发|Vue2.x API 学习
- vue|Vue面试常用详细总结
- vue|电商后台管理系统(vue+python|node.js)
- 腾讯TEG实习|腾讯实习——Vue解决跨域请求
- Vue|vue-router 详解
- vue|vue3替代vuex的框架piniajs实例教程
- Vue|Vue3.0的插槽是如何实现的()
- 前端|面试官(谈谈Vue和React的区别())