在`src/main.js`中增加
```js
axios.defaults.baseURL = '/api'
```
更改`config/index.js`的`proxyTable`为
```js
proxyTable: {
'/api': { //代理地址
target: 'http://domain:port', //需要代理的地址, 实际生产环境需要访问的地址
changeOrigin: true, //是否跨域
secure: false,
pathRewrite: {
'^/api': '' //本身的接口地址没有 '/api' 这种通用前缀,所以要rewrite,如果本身有则去掉
}
}
},
```
0 Comments latest
No comments.