Vue 项目有一个需求,需要对根路径 ‘/’ 进行代理,但同时还存在其余特例路径的访问需求 ‘/py’,例:
- 代理 /* 到 localhost:5000
- 代理 /py/*到 localhost:5001
此时,需要将特例路径的代理写在根路径的前面,否则会被根路径的代理覆盖,无法成功进行代理:
module.exports = {
dev: {
proxyTable: {
'/py': {
target: `localhost:5001`,
changeOrigin: true,
pathRewrite: {
'/py': '',
}
},
'/': {
target: `localhost:5000`,
// secure: true, // 是否 https
changeOrigin: true, // 是否是跨域请求
}
}
}
}









