前沿:不得不說是真的坑的一匹,搞了半天沒搞出來,一直在踩坑中.......
不要設置axios的baseUrl
就是這個玩意: axios.defaults.baseURL = "http://cct.app.xxxxxxxx.top/";
然后就可以了
下面介紹一哈如何在vue cli3 中設定代理:
與main.js同級新建一個vue.config.js的文件
module.exports = { devServer: { port: 8382, https: false, hotOnly: true, //是否開啟熱更新
open: true, //配置自動啟動瀏覽器
proxy: { "/": { target: "http://cct.app.xxxxxxxx.top/", //目標主機
ws: true,//是否代理websockets
changeOrigin: true , // 設置同源 默認false,是否需要改變原始主機頭為目標URL
pathRewrite: { "^/": "/" } } } } };