fix: prevent app crash on missing Supabase env vars - #3
Conversation
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>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
✅ Deploy Preview for pylabssp ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
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
throwwith aconsole.warnwhen env vars are missing.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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); |
There was a problem hiding this comment.
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.
Fixes the "Uncaught Error: Missing Supabase environment variables" crash on startup.
PR created automatically by Jules for task 2223790483192614043 started by @Sujal1201