关于vue-cli开发环境中跨域的处理-配置代理

207 阅读1分钟

配置 config/index.js

 proxyTable: {
  '/v.api': { // 匹配所有以 '/v.api'开头的请求路径
    target: 'http://xxx.xxx.xx.xxx:8080', // 代理目标的基础路径
    changeOrigin: true, // 支持跨域
    pathRewrite: {// 重写路径: 去掉路径中开头的'/v.api'
      '^/v.api': ''
    }
  }
}