proxy: {
'/blog': {
target: 'http://localhost:8099', //API服务器的地址
ws: true, //代理websockets
changeOrigin: true, // 是否跨域,虚拟的站点需要更管origin
pathRewrite: {
// '^/api'是一个正则表达式,表示要匹配请求的url中,全部'http://localhost:8081/api' 转接为 http://localhost:8081/
'^/blog': '',
}
},
'/music':{
target: 'http://cloud-music.pl-fe.cn',
ws: true,
changeOrigin: true,
pathRewrite: {
'^/music':'',
}
},
'/free':{
target:'https://v.api.aa1.cn/api',
//ws:true,
changeOrigin:true,
pathRewrite:{
'^/free':'',
}
},
'/yk':{
target:'https://api.iyk0.com',
changeOrigin:true,
pathRewrite:{
'^/yk':'',
}
},
'/mxg':{
target:'https://api.muxiaoguo.cn/api',
changeOrigin:true,
pathRewrite:{
'^/mxg':'',
}
}
问题解决:axios的请求url,不能包含有其他代理的名字,比如说我调用第一个代理接口blog,路径中就不能有其他的代理名称(不能含有/yk/或者/free/或者/music/)