Skip to content

Commit 93d091a

Browse files
francofrizzoclaude
andcommitted
fix: keep env var validation, only skip in test mode
Throw on missing VITE_SUPABASE_URL/ANON_KEY except when MODE=test (set automatically by vitest). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e892194 commit 93d091a

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/lib/supabaseClient.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { createClient } from "@supabase/supabase-js";
22

3-
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL ?? "http://localhost";
4-
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY ?? "dummy";
3+
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
4+
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY;
55

6-
export const supabase = createClient(supabaseUrl, supabaseAnonKey);
6+
if (!supabaseUrl || !supabaseAnonKey) {
7+
if (import.meta.env.MODE !== "test") {
8+
throw new Error("Missing VITE_SUPABASE_URL or VITE_SUPABASE_ANON_KEY");
9+
}
10+
}
11+
12+
export const supabase = createClient(supabaseUrl ?? "http://localhost", supabaseAnonKey ?? "dummy");

0 commit comments

Comments
 (0)