Skip to content

fix: provide fallback empty strings for Supabase env vars to prevent build failure#3

Closed
circleci-app[bot] wants to merge 1 commit into
mainfrom
chunk/changes-1775574368052-1775574368052
Closed

fix: provide fallback empty strings for Supabase env vars to prevent build failure#3
circleci-app[bot] wants to merge 1 commit into
mainfrom
chunk/changes-1775574368052-1775574368052

Conversation

@circleci-app

@circleci-app circleci-app Bot commented Apr 7, 2026

Copy link
Copy Markdown

Prompt Given

Fix build (17), with failed step Build Next.js

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()

View more about this proposed fix in the CircleCI web app →

…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()`
@vercel

vercel Bot commented Apr 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
racs Error Error Apr 7, 2026 3:06pm

@sonarqubecloud

sonarqubecloud Bot commented Apr 7, 2026

Copy link
Copy Markdown

@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 medium

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
BestPractice 1 medium

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes. Give us feedback

@circleci-app circleci-app Bot closed this Apr 7, 2026
@LCSOGthb LCSOGthb deleted the chunk/changes-1775574368052-1775574368052 branch April 10, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants