Skip to content

fix(web): recognise secure auth session cookies#829

Merged
simonjcarr merged 1 commit intomainfrom
codex/fix-auth-cookie-redirect-loop
Apr 30, 2026
Merged

fix(web): recognise secure auth session cookies#829
simonjcarr merged 1 commit intomainfrom
codex/fix-auth-cookie-redirect-loop

Conversation

@simonjcarr
Copy link
Copy Markdown
Collaborator

Summary

  • make the Next proxy recognise Better Auth secure session cookie variants
  • move session cookie-name handling into a tested helper
  • add focused coverage for unprefixed, __Secure-, and __Host- session cookies

Root cause

In HTTPS production-like runs, Better Auth can set a secure-prefixed session cookie such as __Secure-better-auth.session_token. The login page asks Better Auth directly and treats that cookie as authenticated, redirecting /login to /dashboard. The Next proxy only checked better-auth.session_token, so it treated /dashboard as unauthenticated and redirected back to /login, causing a browser redirect loop.

Validation

  • node --experimental-strip-types --test lib/auth/session-cookie-names.test.mjs
  • npm run lint -- proxy.ts lib/auth/session-cookie-names.ts lib/auth/session-cookie-names.test.mjs
  • npm run type-check
  • Docker production build of ct-ops-web-local
  • Browser verification with @browser-use: http://localhost:3000/dashboard loads Overview | CT-Ops after sign-in

@simonjcarr simonjcarr force-pushed the codex/fix-auth-cookie-redirect-loop branch from b9b746b to a16ac47 Compare April 30, 2026 21:37
@simonjcarr simonjcarr changed the title [codex] fix web auth cookie redirect loop fix(web): recognise secure auth session cookies Apr 30, 2026
@simonjcarr simonjcarr marked this pull request as ready for review April 30, 2026 21:45
@simonjcarr simonjcarr merged commit a3e30c1 into main Apr 30, 2026
19 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 30, 2026
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