Skip to content

docs: explain running a headless frontend behind a same-origin proxy - #159

Merged
entity merged 8 commits into
mainfrom
docs/headless-behind-a-proxy
Dec 3, 2026
Merged

entity merged 8 commits into
mainfrom
docs/headless-behind-a-proxy

Conversation

@RobertBoes

@RobertBoes RobertBoes commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Expands the "One Origin" part of the headless guide for a frontend that passes requests on to Laravel from its own origin, such as a Nuxt or Next.js server route under /backend, so the browser only ever talks to the site.

  • Adds The Proxy: pass Accept and X-Requested-With on, don't follow redirects, pass every cookie both ways, pass the CSRF headers on, leave SESSION_DOMAIN empty, don't cache. Each rule says what breaks without it, including the followed redirect that leaves the browser on a replaced session ID and surfaces later as a passkey sign in failing with a 422.
  • Adds Forwarded Headers: trust only the proxy, and replace X-Forwarded-For, -Host, -Proto and -Port rather than appending to what the browser sent. A table shows what each one feeds (rate limits, security log, risk signals, redirect URLs, cookie flags), and where the prefix does and doesn't reach. Keyring's emailed links and SSO callback never carry it, but a linkRootUsing() built from the request does.
  • Adds With Next.js: a route handler with manual redirects, and why a rewrites() entry gives no say over the forwarded headers.
  • Fixes the Nuxt example. It didn't pass Accept on, let h3 follow redirects, took the scheme from the socket (plain HTTP behind a TLS-terminating load balancer), and let a client-sent X-Forwarded-Port through.
  • Adds to What Changes: passkeys come from APP_URL or the webauthn settings, never the forwarded headers, and the SSO callback lands on the frontend's page. Sign out's Clear-Site-Data now clears the frontend's own storage too, and the package's baseUrl includes /backend.
  • Adds Troubleshooting, mapping 12 symptoms to their causes.
  • Fixes frontend.md, which suggested configureRoutes({ prefix: 'backend/auth' }) for this layout. The url prop of the pages emailed links open is a path without the prefix, so those pages would post to the frontend. It now recommends baseUrl.
  • Mentions the layout in the docs index.

Docs only. The h3 behaviour was checked against h3 1.12–1.15's source. The rewrites() behaviour was checked against the published Next.js 14.2.35 and 16.5.0 source, and the doc describes what a rewrite does with the forwarded headers without naming the library, so it stays true across versions.

To test: every relative link and anchor in the changed pages resolves. No docs test reads these pages.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@entity entity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! The rewrites one is the only one I'd change before merging, the rest are nice to haves

Comment thread docs/headless.md Resolved
Comment thread docs/headless.md Resolved
Comment thread docs/headless.md Resolved
Comment thread docs/headless.md Resolved
Comment thread docs/headless.md Resolved
Comment thread docs/headless.md Resolved
Comment thread docs/headless.md Resolved
@entity
entity merged commit c00554d into main Dec 3, 2026
7 checks passed
@entity
entity deleted the docs/headless-behind-a-proxy branch December 3, 2026 15:51
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.

2 participants