Files
CatoandClaude 8c7fea70b4 fix(middleware): redirect on the public origin, not the proxy's (#224)
Since AUTH_RUNTIME=accountkit (2026-11-01 ~17:00 UTC) the middleware read
the session through AccountKit instead of Auth.js. Auth.js had rebuilt the
request from AUTH_URL; the raw request behind Caddy carries the address the
app listens on, so every redirect went to https://localhost:4005. The home
page's prefetch of /contact got 307 to https://localhost:4005/login, the CSP
blocked it, the page never went network-idle, and every deploy's page check
read "did not load" and rolled back.

- Redirects build on the configured public URL (NEXTAUTH_URL / AUTH_URL),
  in lib/security/public-url.ts; runtime.ts reuses the same siteUrl().
- /contact, /pricing and /roadmap are landing pages in the sitemap and are
  now public (exact paths, so /contacts stays guarded).
- A middleware test with a proxied request fails without the fix
  (Received: https://localhost:4005/login...).


Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-01 23:10:42 +01:00
..