參考文章
正文
- 錯誤截圖
image.png
依照上面找到的兩篇不同的文章,最終推論出以下修改方法,親測有效。
- 修改
vue.config.js文件的devServer.proxy中的每個代理地址(設(shè)置的 600000 是與 axios 中保持一直)
module.exports = {
/**
* 接口代理配置
* 如果你的前端應(yīng)用和后端 API 服務(wù)器沒有運(yùn)行在同一個主機(jī)上,你需要在開發(fā)環(huán)境下將 API 請求代理到 API 服務(wù)器。
* https://cli.vuejs.org/zh/config/#devserver-proxy
* https://github.com/chimurai/http-proxy-middleware#proxycontext-config
*/
devServer: {
port: 9527,
disableHostCheck: true,
proxy: {
'/jwt': {
target: 'http://localhost:8765',
ws: true,
changeOrigin: true,
pathRewrite: {
'^/jwt': '/jwt'
},
timeout: 600000
},
'/api': {
target: 'http://localhost:8765',
ws: true,
changeOrigin: true,
pathRewrite: {
'^/api': '/api'
},
timeout: 600000
}
}
}
}
