vue-cli跨域问题解决
axios里面的baseurl:
https://sit.tohours.com/api |
vue.config.js里面添加如下代码:
devServer: {
proxy: {
'/api': {
target: 'http://ngrokzyj.free.idcfengye.com',
changeOrigin: true,
ws: true,
pathRewrite: {
'^/api': ''
}
}
}
}
|
![](https://img2020.cnblogs.com/blog/1187636/202003/1187636-20200317110140613-654073772.png)