版本不一樣可能配置的參數也不一樣
$ npx vue -V
@vue/cli 4.2.3
修改 配置檔案
vue.config.js
devServer: {
port: port,
open: true,
proxy: {
"/api": {
target: "https://www.baidu.cn", //跨域網址
secure: true, // 如果是https接口,需要配置這個參數
changeOrigin: true, //自動修改http header裡面的host
pathRewrite: {
"^/api": "", //路徑的替換規則
}
}
}
}