-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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(remix-express): respect expressjs hostname property when behind reverse proxies #7323
fix(remix-express): respect expressjs hostname property when behind reverse proxies #7323
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 |
Oops, sorry this must have fallen off my radar. Do you want to add a changeset and we can get this merged? |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
@remix-run/express
createsrequest.url
directly from theHost
HTTP header, but when behind a reverse proxy withapp.enable('trust proxy')
set, the actual hostname is provided via Express'sreq.hostname
property, which is a "proxy aware" property that parses eitherHost
orX-Forwarded-Host
headers 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.url
for areturnTo
parameter (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 badLocation
header, 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.js
and verified thatrequest.url
reflected theX-Forwarded-Host
header whenapp.enable('trust proxy')
was set in my Express app.