Repository navigation
Redirect to url with trailing slash, WITHOUT the protocol and host. - #945
Merged
Merged
Conversation
Crow does not know the correct protocol when behind a reverse proxy. So instead, simply redirect to the same url and add a trailing slash. Note, it is now valid for the "Location" header field to be relative. From wikipedia: An obsolete version of the HTTP 1.1 specifications (IETF RFC 2616) required a complete absolute URI for redirection. The IETF HTTP working group found that the most popular web browsers tolerate the passing of a relative URL[3] and, consequently, the updated HTTP 1.1 specifications (IETF RFC 7231) relaxed the original constraint, allowing the use of relative URLs in Location headers.
paulharris
force-pushed
the
fix-redirect-trailing-slash
branch
from
November 13, 2024 04:02
f180244 to
7aef5b3
Compare
Contributor
Author
|
Note that I found that Location required the host in the past, So I think the host+protocol is not required anymore. |
Member
|
https://datatracker.ietf.org/doc/html/rfc7231#section-7.1.2 states this, so solution is conforming to standard. |
gittiver
approved these changes
Nov 29, 2024
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.
Crow does not know the correct protocol when behind a reverse proxy. So instead, simply redirect to the same url and add a trailing slash.
Regarding #915
I've just realised that this fails when behind a reverse proxy.
Situation: running crowcpp as a HTTP behind a HTTPS reverse proxy
Crow wants to redirect.
It sets the location to the full URL, including protocol.
It assumes http:// is correct, as that is what it is running.
But, it needs https:// to correctly hit the reverse proxy...
Why do we need to specify the host? Is there a good reason?
I couldn't see any reasoning given in prior commits or issues.
967adf0#diff-83f8db2c08b899a7b155ca1ddbef781d51babff4553c79cd20fb3a216ffc7780R937
4cdde73#diff-cce8b59e628bdbbe6a329eea27b56b908c8a1d5926a4b44f697f39a301046c93L1402
07042b5#diff-83f8db2c08b899a7b155ca1ddbef781d51babff4553c79cd20fb3a216ffc7780R677