Supabase: “Invalid API key”
Last verified: October 18, 2026
What it means
The Supabase URL or key is wrong, swapped, from another project, or a secret/service key was used where the public anon/publishable key belongs.
How to fix it
Copy the Project URL and the anon (or sb_publishable_) key fresh from Supabase > Project Settings > API Keys into your env vars, then restart. Never put the service_role/secret key in browser code.
Paste this into Supabase
Stop retrying previous fixes. I'm getting this error: "Invalid API key". Likely cause: The Supabase URL or key is wrong, swapped, from another project, or a secret/service key was used where the public anon/publishable key belongs. Before editing, show me the relevant files and confirm the root cause. Then: Copy the Project URL and the anon (or sb_publishable_) key fresh from Supabase > Project Settings > API Keys into your env vars, then restart. Never put the service_role/secret key in browser code. Change only what's necessary, don't delete working code, don't add new libraries unless required, and tell me exactly what you changed and how to verify it.
Your error's a bit different? Paste it and get a fix prompt written for your exact case.
Break the loop — 3 free fixes Still stuck? Get a human fix