1. 没有vue.config.js的配置方法
1.1 在config目录下的index.js里面加入如下所示代码
proxyTable: {
  "/api": { // 不能写成'^/api'
    target: "http://localhost:50000", // 只写域名即可
    ws: true,
    changeOrigin: true, // 允许跨域
    pathRewrite: { // 重写,^/api': '' // 去掉以/api开头的的字符
      '^/api': ''
    }
  }
}
1.2 axios配置的写法如下图所示
 
 
2. 有 vue.config.js的配置方法
proxy: {
'/dev-api': {
    target: 'http://localhost:50000',
    ws: true,
    changeOrigin: true,
    pathRewrite: {
      '^/dev-api': ''
    }
 }
}



















