当前位置:   article > 正文

【vue3.0】同一个项目代理俩个服务地址_vue3多代理服务器地址应用

vue3多代理服务器地址应用

vue.config.js代码

module.exports = {
  // 基本路径
  publicPath: './',
  // eslint-loader 是否在保存的时候检查
  lintOnSave: true,
  // 路径别名
  configureWebpack: {
    devtool: 'source-map',
    resolve: {
      alias: {
        assets: '@/assets',
        components: '@/components',
        views: '@/views',
        utils: '@/utils',
        api: '@/api',
        layout: '@/layout'
      }
    }
  },
  // 全局加载
  css: {
    loaderOptions: {
      sass: {
        prependData: '@import "src/assets/styles/variables.scss";'
      }
    }
  },
  // 服务代理配置
  devServer: {
    disableHostCheck: true,
    https: false,
    port: 8080,
    open: true, // opens browser window automatically
    proxy: {
      // 渠道共享
      '/api/': {
        target: 'http://xxx.com:8080', // 测试环境
        // target: 'http://172.xx.xx.xx:8080/', // 本地环境
        changeOrigin: true,
        pathRewrite: {
          '^/api/': ''
        }
      },
      // 配置
      '/report': {
        target: 'http://192.168.xxx.xx:8090/report', // mq配置
        changeOrigin: true,
        pathRewrite: {
          '^/report/': ''
        }
      }
    }
  }
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/459231
推荐阅读