# vue 开发是解决跨域问题
- 针对于vue-cli 3.0
# 方法
# 添加插件
@cnamts/vue-cli-plugin-proxy
yarn add @cnamts/vue-cli-plugin-proxy
1
# 添加配置 在根目录添加文件
vue.config.js
module.exports = {
pluginOptions: {
proxy: {
enabled: true,
context: '/api',
options: {
target: 'http://localhost:8080',
changeOrigin: true,
ws:true, //websocket
pathRewrite:{
'^/api':''
}
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16