阅读背景:

vue-cli 3.0 axios 跨域请求代理配置及生产环境 baseUrl 配置

来源:互联网 

1. 开发环境跨域配置

在 vue.config.js 文件中:

module.exports = {
  runtimeCompiler: true,
  publicPath: '/', // 设置打包文件相对路径
  devServer: {
    // open: process.platform === 'darwin',
    // host: 'localhost',
    port: 8071,
    // open: true, //配置自动启动浏览器 
    proxy: {
      '/api': {
        target: 'https://127.0.0.1:8100/', //对应自己的接口
        changeOrigin: true,
        ws: true,
        pathRewrite: {
          '^/api': ''
        }
      }
    }
   }, 
}
module.exp



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: