Perform HTTP to HTTPS redirect using 307 status #4778
Merged
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.
302 and 307 basically do the same thing with just one important difference:
The default 302 redirect from express.js tells the browser to repeat the request with the new URL using the GET verb.
When using the 307 status code manually, this tells the browser to repeat the very same request against the new URL using all the same parameters, headers and most important HTTP verbs.
In practice this is important every time you want to change settings or flip a switch or enter your API key (that information will never arrive at the server)
It's even more important when you get to the site through a reverse proxy that doesn't properly set the X-Forwarded-Proto header.