From bc611202cdec062015c33c981da9e3d4e597dc35 Mon Sep 17 00:00:00 2001 From: roshanraj9136 Date: Sat, 13 Jun 2026 02:21:05 +0530 Subject: [PATCH] fix(seed): require SUPABASE_SERVICE_ROLE_KEY, remove silent fallback The seed script fell back to the anon key when SUPABASE_SERVICE_ROLE_KEY was unset. With RLS restricting INSERT on courses/professors to admin, using the anon key causes confusing permission errors. Fail fast with a clear message instead. --- src/lib/seed.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/seed.ts b/src/lib/seed.ts index bc0f15b..1a2f239 100644 --- a/src/lib/seed.ts +++ b/src/lib/seed.ts @@ -4,7 +4,11 @@ import professorsData from './data/professors.json'; import coursesData from './data/courses.json'; const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL!; -const supabaseServiceKey = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!; +const supabaseServiceKey = process.env.SUPABASE_SERVICE_ROLE_KEY; + +if (!supabaseUrl || !supabaseServiceKey) { + throw new Error('NEXT_PUBLIC_SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY must be set to run seed'); +} const supabase = createClient(supabaseUrl, supabaseServiceKey);