Vue 本地开发跨域

vue-cli3

// vue.config.js
module.exports = {
  devServer: {
    proxy: {
      '/api': {
        target: 'http://localhost:3000', //对应自己的接口
        changeOrigin: true,
        ws: true,
        pathRewrite: {
          '^/api': ''
        }
      }
    }
  }
}

// ajax

// 请求 http://localhost:8080/api/XXXXXX 
// 实际请求  http://localhost:3000/XXXXXX