Lovable
auth
Supabase Anon Key Exposed in Client Code
Supabase anon key is visible in browser. Someone could copy it and use it to call Supabase API directly. Key is committed to Git. Security concern: data exposed via anon key.
Anon keys must be exposed on client but should never have direct table access. RLS policies protect data from unauthorized access even with key.
Common Causes
- No RLS policies on tables (anon key has full access)
- Anon key committed to Git instead of .env
- Anon key used in hard-coded strings
- Not rotating key after accidental exposure
- RLS policies not checking auth.uid() properly
How to Fix It
Use environment variables:
// .env.local (add to .gitignore)
VITE_SUPABASE_URL=...
VITE_SUPABASE_ANON_KEY=...Always implement RLS policies. Anon key with RLS is secure even if exposed. Rotate key in Supabase dashboard if compromised.
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get Help