【发布时间】:2017-07-26 10:00:38
【问题描述】:
node-http-proxy 有没有一种方便的方法来重写包括参数在内的整个 url?
我想做类似的事情:
module.exports = () => ({
"customer/:customerId":"customer?id=:customerId"
});
所以我希望将 customerId 例如重写为名为 id 的 url 参数。
是否可以通过 node-http-proxy 或扩展来实现?
【问题讨论】:
-
google的第一个结果..gist.github.com/indexzero/9087173
-
是的 - 我已经看到了。不支持url参数,无法解决问题
-
req 对象确实包含参数。 req.params
-
是的。所以这并不能解决问题。请看我上面的代码示例。我想要这样的东西。例如。重写 customer/3 -> customer?id=3
-
所以你想在一个地方有一个代理配置。这是你要求的吗?抱歉,这不是很容易解释。
标签: node.js proxy node-http-proxy