VUE-cli构建的项目,反向代理是如何做正则匹配?

// see http://vuejs-templates.github.io/webpack for documentation.
var path = require('path')

module.exports = {
  build: {
    env: require('./prod.env'),
    port: 8081,
    index: path.resolve(__dirname, '../dist/index.html'),
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    productionSourceMap: true,
    // Gzip off by default as many popular static hosts such as
    // Surge or Netlify already gzip all static assets for you.
    // Before setting to `true`, make sure to:
    // npm install --save-dev compression-webpack-plugin
    productionGzip: false,
    productionGzipExtensions: ['js', 'css']
  },
  dev: {
    env: require('./dev.env'),
    port: 8080,
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {
      '/mspapi/': {
        target: 'http://172.16.11.197:8000',
        changeOrigin: true,
        pathRewrite: {
          '^/mspapi/': '/'
        }
      },
      '/sec_standard/':{
        target:"http://172.16.11.197:8000",
        changeOrigin:true
      },
      '^/apk_risk_':{
        target:"http://172.16.11.197:8000",
        changeOrigin:true
      }
    }
  }
}

我看webpack里面配置
是这样的

        proxy: [
            {
                path: /\/google(.*)/,
                target: "http://www.google.com/"
            }
        ],

但是 我用vue cli构建的项目
俩面 设置这个只有在 proxyTable里面这样设置

 proxyTable: {
      '/mspapi/': {
        target: 'http://172.16.11.197:8000',
        changeOrigin: true,
        pathRewrite: {
          '^/mspapi/': '/'
        }
      },
      '/sec_standard/':{
        target:"http://172.16.11.197:8000",
        changeOrigin:true
      },
      '^/apk_risk_':{
        target:"http://172.16.11.197:8000",
        changeOrigin:true
      }
    }

最后一个是我 试试可不可以支持 正则
但好像不对

求指点

阅读 6.7k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题