vue-axios 解决跨域问题
作者:
ai耳边的呢喃 | 来源:发表于
2019-01-30 16:10 被阅读0次
vue3.0环境下
devServer: {
proxy: {
"/api": {
target: "http://192.168.0.201:12386", // 要请求的后台地址
ws: true, // 启用websockets
changeOrigin: true, // 是否跨域
pathRewrite: {
"^/api": "/" // 这里理解成用‘/api’代替target里面的地址,后面组件中我们调接口时直接用api代替
}
},
"/log": {
target: "http://192.168.0.201:12368", // 另一个要请求的地址
ws: true,
changeOrigin: true,
pathRewrite: {
"^/log": "/"
}
}
}
}

image.png
三,在接口前加上代理的api

image.png

image.png
本文标题:vue-axios 解决跨域问题
本文链接:https://www.haomeiwen.com/subject/xflcsqtx.html
网友评论