Repository navigation
fix(remix-express): respect expressjs hostname property when behind reverse proxies - #7323
Merged
brophdawg11 merged 6 commits intoOct 23, 2023
Merged
brophdawg11 merged 6 commits into
brophdawg11 merged 6 commits into
Conversation
🦋 Changeset detectedLatest commit: a3c2c0e The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
brophdawg11
reviewed
Sep 13, 2023
rossipedia
commented
Sep 15, 2023
brophdawg11
approved these changes
Sep 20, 2023
Contributor
|
Oops, sorry this must have fallen off my radar. Do you want to add a changeset and we can get this merged? |
Contributor
|
🤖 Hello there, We just published version Thanks! |
Contributor
|
🤖 Hello there, We just published version Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@remix-run/expresscreatesrequest.urldirectly from theHostHTTP header, but when behind a reverse proxy withapp.enable('trust proxy')set, the actual hostname is provided via Express'sreq.hostnameproperty, which is a "proxy aware" property that parses eitherHostorX-Forwarded-Hostheaders depending on the app configuration.This can cause unexpected behavior when a user requests (for example)
https://remix-app.org.com/page, but some condition causes a redirect to be thrown that usesrequest.urlfor areturnToparameter (for instance: auth failure due to a protected resource).If the app is behind a reverse proxy, and utilizing an internal DNS name (like an AWS internal host name), then that host will be used to create
request.url, and you'll get a response with a badLocationheader, and will also be leaking internal hostnames externally.For example:
Request:
Response:
Closes: #
Testing Strategy:
Made the change to
node_modules/@remix-run/express/dist/server.jsand verified thatrequest.urlreflected theX-Forwarded-Hostheader whenapp.enable('trust proxy')was set in my Express app.