Skip to content

Derive the Supabase auth cookie name from NEXT_PUBLIC_SUPABASE_URL - #261

Merged
ralyodio merged 1 commit into
masterfrom
ops/supabase-auth-cookie-name
Sep 25, 2026
Merged

ralyodio merged 1 commit into
masterfrom
ops/supabase-auth-cookie-name

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

Five API routes (auth/backup-pin, auth/key-backup, chat/conversations/[id]/participants, crypto/public-keys, crypto/public-keys/all) read the session cookie by the literal name sb-xydzwxwsbgmznthiiscl-auth-token. supabase-js names the cookie after the first host label of the project URL (sb-${hostname.split('.')[0]}-auth-token), so when the project moves to the self-hosted stack at https://supabase.qrypt.chat the cookie becomes sb-supabase-auth-token and these routes would see every user as logged out.

src/lib/supabase/auth-cookie.js now derives the name from NEXT_PUBLIC_SUPABASE_URL; the routes and their tests use it. No behaviour change while the URL is still the cloud project.

Part of moving qrypt.chat's database onto its own Supabase stack on dev2.

🤖 Generated with Claude Code

Five API routes read the session cookie by its cloud-derived name
sb-xydzwxwsbgmznthiiscl-auth-token. supabase-js names it after the first
host label of the project URL, so once the project lives at
supabase.qrypt.chat the cookie is sb-supabase-auth-token and those routes
would treat every user as logged out. Compute it from the URL instead.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

ThreatCrush Security Scan

13 finding(s)

MEDIUM: 9 | LOW: 4

Severity Rule Location
MEDIUM redos-nested-quantifier src/app/api/profile/update/route.js:73
MEDIUM js-unescaped-html-sink src/app/blog/[slug]/page.jsx:38
MEDIUM js-unescaped-html-sink src/app/blog/[slug]/page.jsx:66
MEDIUM js-unescaped-html-sink src/app/faq/page.jsx:57
MEDIUM js-unescaped-html-sink src/app/layout.jsx:137
MEDIUM js-unescaped-html-sink src/app/layout.jsx:141
MEDIUM js-unescaped-html-sink src/app/page.jsx:47
MEDIUM redos-nested-quantifier src/lib/auth/dns-name.js:88
MEDIUM js-unescaped-html-sink src/lib/components/chat/MessageItem.jsx:60
LOW secret-generic-credential src/app/api/auth/register-anon/route.test.js:32
LOW secret-jwt tests/debug-sms.js:10
LOW secret-generic-credential tests/private-key-import-export.test.js:252
LOW secret-generic-credential tests/private-key-import-export.test.js:264

Snippets are redacted; ThreatCrush never prints matched credential material.

@ralyodio
ralyodio merged commit 91e03ba into master Sep 25, 2026
10 checks passed
@ralyodio
ralyodio deleted the ops/supabase-auth-cookie-name branch September 25, 2026 14:15
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