If user set a customized header host field, the host should not be changed while sending request.
However, when using proxy config and default adapter http in nodejs, the host header will be reset to request url no matter config headers.host field is set or not.
example:
axios.get("http://127.0.0.1:4000", {
headers: {
host: "example.com",
},
proxy: {
protocol: "http",
host: "127.0.0.1",
port: 8888,
},
});
proxy request should keep header host field as example.com instead of 127.0.0.1:4000
before:
GET / HTTP/1.1
host 127.0.0.1:4000
fix:
GET / HTTP/1.1
host example.com
If user set a customized header
hostfield, thehostshould not be changed while sending request.However, when using
proxyconfig and default adapterhttpin nodejs, thehostheader will be reset to requesturlno matter configheaders.hostfield is set or not.example:
proxy request should keep header
hostfield asexample.cominstead of127.0.0.1:4000before:
fix: