Connect Supabase first: pick or make a project, and only the secret key is pasted

Signs in to the whole Supabase account, lists its projects (one is used straight away), or makes a free one called broke,
then fills in the address and public key and creates the tables. The paste-all-three route stays as the fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
minimus7andClaude Opus 5.5 committed 2026-11-09 11:04:06 -06:00
1 parent 73208b79df
commit 0e1a05801c
9 files changed
+237 -20

No files matched your search

+2 -2
View File
@@ -4,12 +4,12 @@ import { refFromUrl, startConnect } from "@/lib/supabase-mcp";
const LOOPBACK = /^(localhost|127\.0\.0\.1|\[::1\])(:\d+)?$/;
// "Connect Supabase": returns the Supabase approval page for this project. Localhost only.
// "Connect Supabase": returns the Supabase approval page, for this project or (before one is set) the whole account. Localhost only.
export async function POST(request: Request) {
const host = request.headers.get("host") ?? "";
if (!LOOPBACK.test(host) || !(await setupAccess()).allowed) return NextResponse.json({ error: "Only on this computer." }, { status: 403 });
// No project yet: sign in to the whole account, and broke picks (or makes) the project after.
const ref = refFromUrl(currentEnv().NEXT_PUBLIC_SUPABASE_URL);
if (!ref) return NextResponse.json({ error: "Add your Supabase Project URL first." }, { status: 400 });
try {
const url = await startConnect(ref, `http://${host}/api/setup/supabase/callback`);
return NextResponse.json(url ? { url } : { connected: true });