javascript - VUE-cli构建的项目,反向代理是如何做正则匹配?
迷茫
迷茫 2017-04-11 12:28:17
0
1
326
// 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
      }
    }

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

求指点

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

全部回覆(1)
刘奇

参考:https://github.com/chimurai/h...

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!