Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(proxy): keep request header host if user set it while using proxy #6439

Open
wants to merge 1 commit into
base: v1.x
Choose a base branch
from

Conversation

scplay
Copy link

@scplay scplay commented Jun 8, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant