鍍金池/ 問答/HTML/ wepack.config.js 配置問題

wepack.config.js 配置問題

webpack devServer怎么重寫請(qǐng)求路徑

例如 http://localhost/client/abc.do 重寫為 http://abc.com/abc.do 我想將client路徑下的請(qǐng)求都轉(zhuǎn)發(fā)到abc.com上
<pre>
devServer: {

    proxy: {
          pathRewrite : function (path,req){ 
              return 
      'http://serverProxy.com'+path.replace(/\/client(.*)/,function($1,$2){return $2});
          }
    }
 } 

</pre>
這么寫好像不行

回答
編輯回答
祈歡
  devServer: {
    proxy: {
      '/client': {
        target: 'http://abc.com',
        pathRewrite: {
          '^/client': ''
        }
      }
    }
  }
2017年10月9日 03:51