Skip to content

T-085: The JSDoc and the docs of request.authority() match its behaviour - #151

Merged
thetutlage merged 1 commit into
9.xfrom
task/T-085
Nov 16, 2026
Merged

thetutlage merged 1 commit into
9.xfrom
task/T-085

Conversation

@fleet-panda

@fleet-panda fleet-panda Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Goal

request.authority() returns the HTTP/2 :authority pseudo-header and falls back to request.host(), which uses X-Forwarded-Host when the request comes from a proxy that trustProxy trusts. This behaviour stays (#149). Its JSDoc and one docs page said that it falls back to the raw Host header and never uses X-Forwarded-Host. They change to say what the code does.

Deployment requirements

  • No package needs a release. The JSDoc ships with the next release of @adonisjs/http-server.

Acceptance criteria

  • The JSDoc of authority() in src/request.ts of http-server says that it falls back to host(), and so uses X-Forwarded-Host from a trusted proxy. Proof: the diff of src/request.ts, and the new test "authority falls back to the forwarded host from a trusted proxy", which passes. Result: pass.
  • The "Redirecting back" part of content/guides/basics/response.md in v7-docs says that the current request's host is the :authority pseudo-header or request.host(), which uses X-Forwarded-Host from a trusted proxy. Proof: the diff of the page, and the screenshot below. Result: pass.
  • The code of authority() does not change. Proof: the diff of src/request.ts changes only the comment above authority(). Result: pass.

Also: the JSDoc of getPreviousUrl() in src/helpers.ts said (:authority or Host). It now says request.host().

Checks: http-server lint, typecheck and quick:test (669 tests) pass. v7-docs lint and typecheck pass.

Screenshots

Response page, "Redirecting back", width 1440 px:

Response page, Redirecting back, 1440 px

Context changes

None.

Discovered work

  • trustProxy() in src/utils.ts of http-server caches its result by the remote address only. It does not use the proxyFn in the key of the cache. In one process, two servers with a different trustProxy config get the cached result of the first server for the same address.

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
@fleet-panda

fleet-panda Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Triage: Nothing to do. The only change is a Cloudflare Pages deploy comment on adonisjs/v7-docs#97, and the deploy passed.

@thetutlage
thetutlage merged commit 063954f into 9.x Nov 16, 2026
10 checks passed
@thetutlage
thetutlage deleted the task/T-085 branch November 16, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant