hostRewrite/autoRewrite clarity
From the Readme:
hostRewrite: rewrites the location hostname on (201/301/302/307/308) redirects.
autoRewrite: rewrites the location host/port on (201/301/302/307/308) redirects based on requested host/port. Default: false.
The following is not clear:
- How does
hostRewriterewrite? To the target? To the response header? - What is the precedence of these options? Seems that they are not logically compatible.
- What is the
hostRewritedefault?
please answer... I want to know that, too...
https://github.com/http-party/node-http-proxy/blob/a3fe02d651d05d02d0ced377c22ae8345a2435a4/lib/http-proxy/passes/web-outgoing.js#L50-L73
hostRewrite expects a string, default is null autoRewrite is a boolean and uses the Host header from the request, default is false
given that my frontend has hostname as www.frontend.com and the target or backend has hostname as my.internal.io, and my internal web server has generated some anchor links in html with href pointing to absolute internal URL, e.g Foo page href="https://my.internal.io/foo.html", I'm wondering if the http-proxy could automatically rewrite the above mentioned anchor as following via hostRewrite: Foo page href="https://www.frontend.com/foo.html" otherwise, the Foo Page link won't be accessible from a browser since it has an unreachable internal URL