diff --git a/src/app/api/setup/supabase/connect/route.ts b/src/app/api/setup/supabase/connect/route.ts
index b4feee4..41e307e 100644
--- a/src/app/api/setup/supabase/connect/route.ts
+++ b/src/app/api/setup/supabase/connect/route.ts
@@ -11,7 +11,8 @@ export async function POST(request: Request) {
// 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);
try {
- const url = await startConnect(ref, `http://${host}/api/setup/supabase/callback`);
+ const { fresh } = (await request.json().catch(() => ({}))) as { fresh?: boolean };
+ const url = await startConnect(fresh ? undefined : ref, `http://${host}/api/setup/supabase/callback`, !!fresh);
return NextResponse.json(url ? { url } : { connected: true });
} catch (e) {
console.error("[broke] supabase connect:", e instanceof Error ? e.message : e);
diff --git a/src/app/setup/SetupActions.tsx b/src/app/setup/SetupActions.tsx
index be360de..516ae52 100644
--- a/src/app/setup/SetupActions.tsx
+++ b/src/app/setup/SetupActions.tsx
@@ -171,20 +171,20 @@ export function MigrateButton({ onDone }: { onDone: () => void }) {
}
// One click: Supabase's own sign-in page, then back to /setup with the tables created.
-export function ConnectSupabaseButton({ onDone, onFail }: { onDone: () => void; onFail?: () => void }) {
+export function ConnectSupabaseButton({ onDone, onFail, fresh = false, label = "Connect Supabase", quiet = false }: { onDone: () => void; onFail?: () => void; fresh?: boolean; label?: string; quiet?: boolean }) {
const [busy, setBusy] = useState(false);
const [msg, setMsg] = useState("");
return (
{msg && {msg}}
@@ -245,6 +245,10 @@ export function ProjectPicker({ onDone }: { onDone: () => void }) {
{busy === "new" ? "Making your project… about a minute" : "Make a new free project called broke"}
{msg &&
{msg}
}
+
+
+
Signs in to Supabase again, so you can choose the organization that has the project you want.
+
);
}
diff --git a/src/lib/supabase-mcp.ts b/src/lib/supabase-mcp.ts
index 99e6f57..efdd966 100644
--- a/src/lib/supabase-mcp.ts
+++ b/src/lib/supabase-mcp.ts
@@ -63,7 +63,9 @@ export const mcpConnected = (ref?: string) => {
/** Starts the sign-in. Returns the Supabase approval page to send the browser to, or null if already signed in. */
// ref undefined: sign in to the whole account, so broke can list projects and fill in the URL and public key itself.
-export async function startConnect(ref: string | undefined, redirect: string): Promise {
+export async function startConnect(ref: string | undefined, redirect: string, fresh = false): Promise {
+ // fresh: forget this sign-in, so Supabase asks again (and the person can pick a different organization).
+ if (fresh) save({ client: undefined, tokens: undefined, ref: undefined, all: undefined });
const s = load();
const all = !ref;
// A new project, a change between one project and the whole account, or a new callback address needs fresh tokens.