SIGN IN SIGN UP
withastro / astro UNCLAIMED

The web framework for content-driven websites. ⭐️ Star to support our work!

0 0 109 TypeScript

Resolve X-Forwarded-* headers inside FetchState (#16811)

* Resolve X-Forwarded-* headers inside FetchState

Previously, X-Forwarded-Proto/Host/Port headers were resolved before
the Fetchable handler's fetch() method was called, so headers set by
user code in src/app.ts had no effect on Astro.url.

Move the forwarded header resolution into FetchState's constructor so
it reads from request.headers at the right time. This lets custom
fetch handlers set or modify forwarded headers before creating
FetchState.

Also removes the now-redundant forwarded header processing from the
dev server's handleRequest() in vite-plugin-app/app.ts.

Closes #16797

* Short-circuit forwarded header resolution when no headers present

* Add createRequestFromNodeRequest to skip redundant forwarded header validation

Internal call sites that go through app.render() (which creates a
FetchState) no longer duplicate the X-Forwarded-* validation work.
The public createRequest is preserved for external adapters.

* Restore X-Forwarded-For client address resolution in createRequestFromNodeRequest

* fix(perf): restore actions memoization lost during merge

* perf(bisect): disable forwarded headers check in FetchState constructor
M
Matthew Phillips committed
e0e26dbfe95f9d42f51ad414dbe877e60cbc637d
Parent: 1b1251f
Committed by GitHub <noreply@github.com> on 5/27/2026, 4:32:14 PM