Skip to content

fix: prevent app crash on missing Supabase env vars - #3

Open
Sujal1201 wants to merge 1 commit into
mainfrom
fix/supabase-env-vars-2223790483192614043
Open

fix: prevent app crash on missing Supabase env vars#3
Sujal1201 wants to merge 1 commit into
mainfrom
fix/supabase-env-vars-2223790483192614043

Conversation

@Sujal1201

Copy link
Copy Markdown
Owner

Fixes the "Uncaught Error: Missing Supabase environment variables" crash on startup.


PR created automatically by Jules for task 2223790483192614043 started by @Sujal1201

Changed `src/lib/supabase.ts` to use placeholder values and a console warning
instead of throwing an error when Supabase environment variables are missing.
This prevents the application from failing to render completely (white screen)
when the variables are not set yet.

Co-authored-by: Sujal1201 <151530482+Sujal1201@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings March 24, 2026 14:32
@netlify

netlify Bot commented Mar 24, 2026

Copy link
Copy Markdown

Deploy Preview for pylabssp ready!

Name Link
🔨 Latest commit deb20bd
🔍 Latest deploy log https://app.netlify.com/projects/pylabssp/deploys/69c2a08a4f33a30008904854
😎 Deploy Preview https://deploy-preview-3--pylabssp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@vercel

vercel Bot commented Mar 24, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
pythonlabs Ready Ready Preview, Comment Mar 24, 2026 2:33pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts Supabase client initialization to avoid crashing the app at startup when VITE_SUPABASE_URL / VITE_SUPABASE_ANON_KEY are missing.

Changes:

  • Adds placeholder fallback values for Supabase URL and anon key.
  • Replaces the startup throw with a console.warn when env vars are missing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/supabase.ts
Comment on lines +4 to 11
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL || 'https://placeholder.supabase.co';
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY || 'placeholder';

if (!supabaseUrl || !supabaseAnonKey) {
throw new Error('Missing Supabase environment variables');
if (!import.meta.env.VITE_SUPABASE_URL || !import.meta.env.VITE_SUPABASE_ANON_KEY) {
console.warn('Missing Supabase environment variables. Using placeholder values.');
}

export const supabase = createClient<Database>(supabaseUrl, supabaseAnonKey);

Copilot AI Mar 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using hard-coded placeholder values means the app will still create a Supabase client and attempt real network calls (e.g., in App.tsx on startup) against https://placeholder.supabase.co with a bogus key. This can cause confusing runtime failures, slow startup, and can unintentionally send requests to an external domain when the app is misconfigured. Safer pattern: only create/export a real client when both env vars are present; otherwise export null/undefined (or a stub that throws on use) plus an isSupabaseConfigured flag so callers can skip data loading and show a configuration error screen.

Copilot uses AI. Check for mistakes.
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.

2 participants