Short answer
Copy the publishable key and the URL from the same project’s API settings, set them in your host’s environment variables, and rebuild. If legacy keys were disabled or a key was rotated, move the app to the current publishable key. Send keys on the apikey header.
Rather not fix it yourself? App Fix Ticket starts with a fixed-price diagnosis, then a fixed price for the fix before any fix work.
Why Supabase rejects the key, and the fix
01
The production build has the wrong key
Next.js, Vite and similar frameworks inline public env variables at build time. A key changed in Vercel or Netlify after the build keeps the old value until you rebuild. Check for stray quotes, spaces or a cut-off key too.
02
The key was disabled or rotated
“They stay valid until you disable them in the Settings > API Keys section of the Dashboard, which is a separate step.” Supabase docs, Understanding API keys
An app that still ships the anon key stops working once legacy keys are disabled, and a rotated secret key fails everywhere the old one was copied. The exact message can differ, so check the API keys page for what is active. Switch to the current key.
03
The URL and key come from different projects
A staging key with the production URL, or the other way round, fails every request. Copy both values from the same project.
04
The key is on the wrong header
“Send publishable and secret keys on the apikey header, not on Authorization: Bearer.” Supabase docs, Understanding API keys (known limitations)
The new keys are not JWTs. Send them on apikey, which supabase-js does for you, and keep Authorization for a user’s session token. Sent only as a Bearer token they fail with a different error, so check this when you call the REST API by hand.
Checked against the vendor’s docs on : Supabase docs: Understanding API keys.
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug in an existing mobile or web app, diagnosed and fixed.See scope and start
- from $450AI-Built App RescueA Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.See scope and start
“Very responsive, attentive to fixing bugs, and completed the project as needed! Thank you!”
Related: Supabase JWSError JWSInvalidSignature · Supabase anon key exposed · Supabase Edge Function 401 Invalid JWT · Supabase Storage InvalidKey