Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
463 views
in Technique[技术] by (71.8m points)

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
      }
    }

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

求指点


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...