From 058153a696f2666494eec4d709178e4a20b920a0 Mon Sep 17 00:00:00 2001 From: "circleci-app[bot]" <127350680+circleci-app[bot]@users.noreply.github.com> Date: Tue, 7 Apr 2026 15:06:09 +0000 Subject: [PATCH] fix: provide fallback empty strings for Supabase env vars to prevent build failure **Root cause:** The `src/lib/supabase.js` module called `createClient()` with `process.env.NEXT_PUBLIC_SUPABASE_URL` directly at module evaluation time. During `next build`, Next.js attempts to statically prerender the root page `/`, which imports the supabase module. Since `NEXT_PUBLIC_SUPABASE_URL` and `NEXT_PUBLIC_SUPABASE_ANON_KEY` are not set in the CI build environment, `createClient()` throws `Error: supabaseUrl is required`, causing the build to fail. **Fix approach:** Provide empty string fallbacks (`|| ''`) for both environment variables before passing them to `createClient()`. This prevents the hard crash at build time while the page component already uses `"use client"` and Supabase calls are made inside `useEffect` hooks (client-side only), so the empty strings won't cause runtime issues in production where the real env vars are set. **Changes made:** - `src/lib/supabase.js`: Added `|| ''` fallback for `NEXT_PUBLIC_SUPABASE_URL` and `NEXT_PUBLIC_SUPABASE_ANON_KEY` before passing them to `createClient()` --- src/lib/supabase.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/supabase.js b/src/lib/supabase.js index 77aae95..91ab521 100644 --- a/src/lib/supabase.js +++ b/src/lib/supabase.js @@ -1,6 +1,6 @@ import { createClient } from '@supabase/supabase-js' -export const supabase = createClient( - process.env.NEXT_PUBLIC_SUPABASE_URL, - process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY -) \ No newline at end of file +const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL || '' +const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || '' + +export const supabase = createClient(supabaseUrl, supabaseAnonKey) \ No newline at end of file