http-proxy-middle代码URL的问题

app.use(`/apiProxy`, proxy({

  target: 'http://172.17.123.131:10241',

  // target: 'http://172.17.123.216:4000',

  changeOrigin: true,

  logLevel: 'debug',

  proxyReq: function (req) {

    console.log(req)

  }

}));

when i ajax get('/apiProxy/TaxRate/GetTaxRates') i want to refer to http://172.17.123.131:10241/TaxRate/GetTaxRates


not http://172.17.123.131:10241/apiProxy/TaxRate/GetTaxRates


How did i do this?


浮云间
浏览 806回答 2
2回答

萧十郎

这个中间件有一个pathRewrite属性,你对着文档设置一下就行了。

慕斯王

add pathRewrite like:proxy({    ...    pathRewrite: {          '^/apiProxy' : '/'               },})
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript