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

Preserve Host header and don't follow redirects #1

Merged
merged 1 commit into from Apr 8, 2024

Conversation

mk12
Copy link
Contributor

@mk12 mk12 commented Apr 8, 2024

This includes two changes for more correct reverse proxy behavior:

  • Preserve the "Host" header set by the client, instead of deriving it from the new URL (as fetch does by default). This ensures that e.g. if the service issues a redirect, it will be in terms of servicename.localhost, not 127.0.0.1:7001.

  • Pass { redirect: "manual" } to fetch. This ensures that redirects from the service are sent back to the client, instead of the reverse proxy issuing the request to the new location itself.

This includes two changes for more correct reverse proxy behavior:

* Preserve the "Host" header set by the client, instead of deriving it from the new URL (as `fetch` does by default). This ensures that e.g. if the service issues a redirect, it will be in terms of servicename.localhost, not 127.0.0.1:7001.

* Pass `{ redirect: "manual" }` to fetch. This ensures that redirects from the service are sent back to the client, instead of the reverse proxy issuing the request to the new location itself.
Copy link
Owner

@TomasHubelbauer TomasHubelbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, legend!

@TomasHubelbauer TomasHubelbauer merged commit fe6ae14 into TomasHubelbauer:main Apr 8, 2024
@mk12 mk12 deleted the patch-1 branch April 8, 2024 17:59
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

2 participants