vue-cli3配置跨域

在根目录下创建vue.config.js

// vue.config.js
module.exports = {
    publicPath: '/',
    devServer: {
      proxy: {
        '/api': {
          target: 'https://aip.baidubce.com', //对应自己的接口
          changeOrigin: true,
          secure: false,
          ws: true,
          pathRewrite: {
            '^/api': ''
          }
        }
      }
    }
  }

你可能感兴趣的:(vue-cli3配置跨域)