let proxyObj = {}

proxyObj['/'] = {
  //websocket
  ws: false,
  //目标地址
  target: 'http://116.62.158.92:8081',
  // target: 'https://admin.zfire.top/',
  // target: "https://reportinter.zfire.top",
  //发送请求头host会被设置target
  changeOrigin: true,
  //不重写请求地址
  pathRewrite: {
    '^/api': '/'
  }
}

module.exports = {
  publicPath: './',
  assetsDir: 'static',
  lintOnSave: false, //关闭eslint
  //修改或新增html-webpack-plugin的值，在index.html里面能读取htmlWebpackPlugin.options.title
  chainWebpack: config => {
    config.plugin('html').tap(args => {
      args[0].title = '嘉讯茂移动办公平台'
      return args
    })
  },
  // devServer: {
  //   host: 'localhost',
  //   port: 8080,
  //   proxy: proxyObj,
  //   compress: true,
  //   disableHostCheck: true
  // },
  devServer: {
    host: 'localhost',
    port: 8080,
    proxy: {
      '/api': {
        ws: false,
        //目标地址
        target: 'http://116.62.158.92:8081',
        // target: 'https://admin.zfire.top/',
        // target: "https://reportinter.zfire.top",
        //发送请求头host会被设置target
        changeOrigin: true,
        pathRewrite: {
          '^/api': '/'
        }
      },
      '/services': {
        ws: false,
        //目标地址
        // target: 'http://116.62.158.92:8081',
        target: 'https://admin.zfire.top', //测试,
        // target: 'https://pgxtadm.greeapps.com',
        // target: "https://reportinter.zfire.top",
        //发送请求头host会被设置target
        changeOrigin: true
        // onProxyRes(proxyRes, req, res) {
        //   //在控制台显示真实代理地址
        //   const realUrl = new URL(req.url || '', 'https://admin.zfire.top')?.href || ''
        //   proxyRes.headers['x-real-url'] = realUrl
        // }
      }
    },
    compress: true,
    disableHostCheck: true
  }
}
