vue devServer proxy 代理无效的问题
在vue.config.js中,设置
module.exports = {
publicPath: '/app',
devServer: {
proxy: {
'/test': {
target: 'http://localhost:88',
ws: true,
changeOrigin: true,
pathRewrite: {
'^/test': '/', // rewrite path
},
}
}
}
}
axios中
this.axios.post('/test').then(value => {
console.log(value);
})
这样设置后,却访问不到,原因是,后台也要有 test字段, 这样设置后,后台访问的URL为: http://localhost:88/test ,而不是 http://localhost:88
浙公网安备 33010602011771号