跳到主要内容

vue_proxy

Vue 开发环境经常会遇到跨域请求错误,这时候需要设置 Vue 代理模块。

在 vue.config.js 中编辑,如果没有则创建文件:

module.exports = {
outputDir: 'dist',
devServer: {
proxy: {
'/apis': {
target: 'https://xxx.abc.com/',
ws: true,
changeOrigin: true,
pathRewrite: {
'^/xxx': '',
},
},
},
},

publicPath: '/xxx',
}