wepack.config.js 配置问题

webpack devServer怎么重写请求路径

例如 http://localhost/client/abc.do 重写为 http://abc.com/abc.do 我想将client路径下的请求都转发到abc.com上
<pre>
devServer: {

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

</pre>
这么写好像不行

阅读 1.7k
1 个回答
  devServer: {
    proxy: {
      '/client': {
        target: 'http://abc.com',
        pathRewrite: {
          '^/client': ''
        }
      }
    }
  }
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题