Repository navigation
T-085: The JSDoc and the docs of request.authority() match its behaviour - #151
Merged
Merged
Conversation
The JSDoc of authority() said that it never uses X-Forwarded-Host. It falls back to host(), which uses X-Forwarded-Host from a trusted proxy. A test pins this behaviour. Refs #150
Contributor
Author
|
Triage: Nothing to do. The only change is a Cloudflare Pages deploy comment on adonisjs/v7-docs#97, and the deploy passed. |
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.
Goal
request.authority()returns the HTTP/2:authoritypseudo-header and falls back torequest.host(), which usesX-Forwarded-Hostwhen the request comes from a proxy thattrustProxytrusts. This behaviour stays (#149). Its JSDoc and one docs page said that it falls back to the rawHostheader and never usesX-Forwarded-Host. They change to say what the code does.Deployment requirements
@adonisjs/http-server.Acceptance criteria
authority()insrc/request.tsofhttp-serversays that it falls back tohost(), and so usesX-Forwarded-Hostfrom a trusted proxy. Proof: the diff ofsrc/request.ts, and the new test "authority falls back to the forwarded host from a trusted proxy", which passes. Result: pass.content/guides/basics/response.mdinv7-docssays that the current request's host is the:authoritypseudo-header orrequest.host(), which usesX-Forwarded-Hostfrom a trusted proxy. Proof: the diff of the page, and the screenshot below. Result: pass.authority()does not change. Proof: the diff ofsrc/request.tschanges only the comment aboveauthority(). Result: pass.Also: the JSDoc of
getPreviousUrl()insrc/helpers.tssaid(:authority or Host). It now saysrequest.host().Checks:
http-serverlint, typecheck andquick:test(669 tests) pass.v7-docslint and typecheck pass.Screenshots
Response page, "Redirecting back", width 1440 px:
Context changes
None.
Discovered work
trustProxy()insrc/utils.tsofhttp-servercaches its result by the remote address only. It does not use theproxyFnin the key of the cache. In one process, two servers with a differenttrustProxyconfig get the cached result of the first server for the same address.