chore(web): use env vars for Supabase credentials
Replace hardcoded Lovable-generated URL + anon key in apps/web/src/integrations/supabase/client.ts with import.meta.env.VITE_SUPABASE_* reads. Throw at boot if missing so misconfiguration fails loud instead of silent 401s downstream. Add apps/web/.env.example as template (gitignored .env.local pattern already in repo). VITE_ prefix is intentional — anon key is meant to be client-bundled. Service role keys never go here. Closes Sprint 4 working-tree drift before Sprint 5 work begins. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
79d20482aa
commit
2faa2b2c04
@@ -0,0 +1,9 @@
|
||||
# Vite frontend env. Copy to .env.local and populate.
|
||||
# .env.local is gitignored at repo root (.env*.local pattern).
|
||||
#
|
||||
# Vite exposes ONLY variables prefixed with VITE_ to client bundle.
|
||||
# Never put secrets here (service_role, private keys) — they leak to browser.
|
||||
|
||||
VITE_SUPABASE_URL=https://<project-ref>.supabase.co
|
||||
VITE_SUPABASE_ANON_KEY=eyJ...
|
||||
VITE_API_BASE_URL=http://127.0.0.1:8000
|
||||
@@ -1,11 +1,13 @@
|
||||
// This file is automatically generated. Do not edit it directly.
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
import type { Database } from './types';
|
||||
|
||||
const SUPABASE_URL = "https://ahtbogkmytgrqwxfvodp.supabase.co";
|
||||
const SUPABASE_PUBLISHABLE_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImFodGJvZ2tteXRncnF3eGZ2b2RwIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQyMDExODEsImV4cCI6MjA4OTc3NzE4MX0.Wxwk6jaHiUclbFGT-s4ZO80I1PMxix76CQvW9o76K6Q";
|
||||
const SUPABASE_URL = import.meta.env.VITE_SUPABASE_URL;
|
||||
const SUPABASE_PUBLISHABLE_KEY = import.meta.env.VITE_SUPABASE_ANON_KEY;
|
||||
|
||||
// Import the supabase client like this:
|
||||
// import { supabase } from "@/integrations/supabase/client";
|
||||
if (!SUPABASE_URL || !SUPABASE_PUBLISHABLE_KEY) {
|
||||
throw new Error(
|
||||
"Missing VITE_SUPABASE_URL or VITE_SUPABASE_ANON_KEY. Copy apps/web/.env.example to apps/web/.env.local and populate.",
|
||||
);
|
||||
}
|
||||
|
||||
export const supabase = createClient<Database>(SUPABASE_URL, SUPABASE_PUBLISHABLE_KEY);
|
||||
Reference in New Issue
Block a user