forwardHost option not working with rocky#balance
kacperzuk opened this issue · 2 comments
kacperzuk commented
Consider this snippet:
const proxy = require("rocky")();
const http = require("http");
proxy
.get("/")
//.balance(["http://127.0.0.1:3001"])
.forward("http://127.0.0.1:3001")
.options({ forwardHost: true });
proxy.listen(3000);
// target server
http.createServer((req, res) => {
res.write("Host header received by backend: ");
res.write(req.headers.host);
res.end();
}).listen(3001);
When using forwardHost option with rocky#forward I see 127.0.0.1:3001
in response as expected.
When I try the same with .balance(["http://127.0.0.1:3001"])
instead of .forward(...)
I always get the original Host header (localhost:3000
in my case).
Is that an expected behavior? Looks like useProperHostHeader
in lib/protocols/http/passes/forward.js
is called too early, before target is set.
h2non commented
You're totally right. I'll fix it asap.
h2non commented
This is fixed now. Try it updating rocky
:
npm update rocky
Thank you for reporting.