You built your app with Lovable, Bolt, Cursor or Replit on a Supabase project. Then one day sign-up does nothing, the dashboard stays empty, or a scheduled job stops running. When you look at the failing request, Supabase's reply says Legacy API keys are disabled. Your own browser may still look fine for a while, so the first people to notice are often your users.
The short answer
Every request to Supabase carries an API key. For years that key was a long string starting with eyJ: the anon key for the browser and the service_role key for servers. Supabase now has newer keys: a publishable key (sb_publishable_...) that replaces anon, and a secret key (sb_secret_...) that replaces service_role. Supabase's docs say it is deprecating the anon and service_role keys by the end of 2026.
Both kinds of key work side by side until someone turns the old ones off in the Supabase Dashboard. After that, anything still sending an eyJ key gets refused. The response quoted in a Supabase CLI issue on GitHub reads:
{"message":"Legacy API keys are disabled","hint":"Your legacy API keys (anon, service_role) were disabled on <date>. Re-enable them in the Supabase dashboard, or use the new publishable and secret API keys."}
The date in the hint tells you when it happened, which helps you match it to the day things broke. The fix is to give every caller the new key, then rebuild and redeploy.
This guide is for apps on your own Supabase project. If your app uses Lovable Cloud, Lovable's built-in backend, and you never created a Supabase project yourself, ask Lovable support before you change any keys.
Find out which part of your app still uses an old key
Open your live site in a private window, open the browser's developer tools on the Network tab, and try the thing that is broken: sign up, log in, or open a page that loads data. Click a request to your supabase.co address and read the response.
- The browser request fails with this message: your frontend is still built with the old
anonkey. - The browser requests work, but an Edge Function, webhook or cron job fails: a backend caller is still using the old
service_rolekey. Check your Edge Function logs in Supabase. - Everything in the browser works and nothing fails yet: you still have time. Do the steps below before anyone turns the old keys off.
Supabase's migration guide says there is no automatic indicator of what still uses the old keys, so you have to check each place by hand. It lists ones that are easy to miss: app versions already on people's phones, CI and deploy scripts, third-party integrations and webhooks, cron jobs, workers, and Database Webhooks or pg_net calls.
Fix it in five steps
1. Get the new keys
In the Supabase Dashboard, open Settings, then API Keys, and select the Publishable and secret API keys tab. If you see a Create new API keys button, your project has never had them. Supabase says creating them is safe: it adds a publishable key and a secret key named default next to your old keys without affecting them.
2. Swap the key in your frontend, then rebuild
Anywhere your browser code creates its Supabase client, use the publishable key instead of the anon key. Supabase says the publishable key has the same low privileges as anon, so your Row Level Security rules and your users' logins behave the same.
Check the value, not just the name. A variable called VITE_SUPABASE_PUBLISHABLE_KEY can still hold an old eyJ key. Supabase's docs say that if a tutorial, tool or AI assistant tells you to copy a long key beginning with eyJ, it was written for the old keys.
If the key comes from an environment variable on Vercel, Netlify or another host, change it there and build the site again. Vite says import.meta.env values are replaced at build time, and Next.js says a built app no longer responds to changes in its NEXT_PUBLIC_ variables. Changing the value without a new build changes nothing on the live site.
3. Swap the key in your server code and Edge Functions
Anywhere your server uses the service_role key, use a secret key instead. Keep it on the server: never in browser code, never in a VITE_ or NEXT_PUBLIC_ variable, and never in your code repository. Supabase says a secret key returns 401 Unauthorized if it is used from a browser.
Edge Functions need a code change. Supabase's guide says SUPABASE_ANON_KEY and SUPABASE_SERVICE_ROLE_KEY still exist in the function runtime but carry the old keys. The new keys are in SUPABASE_SECRET_KEYS and SUPABASE_PUBLISHABLE_KEYS, which hold JSON keyed by name:
// before
const secretKey = Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!
// after
const secretKey = JSON.parse(Deno.env.get('SUPABASE_SECRET_KEYS')!)['default']
4. Send the new keys on the right header
The new keys are not JWTs, so anything that tries to read one as a JWT fails. Supabase says to send them on the apikey header, not on Authorization: Bearer. Two places this matters:
- Database Webhooks and
pg_netcalls usually send theservice_rolekey asAuthorization: Bearer. Supabase says to remove that header and add anapikeyheader with a secret key, and to keep the key in Vault rather than typing it into SQL or the webhook settings. - Edge Functions that get the new key on the
Authorization: Bearerheader can reject the request withInvalid JWT. Supabase's guide says the built-inverify_jwtcheck only understands the old keys, so setverify_jwt = falsefor those functions and check the key in your own code, or use Supabase's@supabase/serverSDK, which does it for you.
5. Test like a new visitor, then keep the old keys off
Deploy, then open your live site in a private window. Sign up with a new email, log in, load a page with data, and trigger anything a webhook or Edge Function does. In the Network tab, no Supabase request should say Legacy API keys are disabled.
Supabase says turning the old keys off is reversible, so you can switch them back on in Settings, then API Keys, if you find a caller you missed. Only do that as a short stopgap while you fix that caller. If the old keys were turned off because one leaked, Supabase's guide says to move the missed caller to a new key instead, because switching them back on brings the leaked key back too.
Paste this into your AI tool
> My app uses Supabase and requests fail with "Legacy API keys are disabled". Please find every place the app uses a legacy Supabase key (a long value starting with eyJ, or variables such as SUPABASE_ANON_KEY and SUPABASE_SERVICE_ROLE_KEY). In browser code, read the publishable key (sb_publishable_) from an environment variable instead. In server code and Edge Functions, read the secret key from a server-only environment variable, or from SUPABASE_SECRET_KEYS in Edge Functions, and never put it in browser code, a VITE_ or NEXT_PUBLIC_ variable, or the repository. Send the new keys on the apikey header, not Authorization: Bearer. Do not hardcode any key. Then list the environment variables I need to change on my host and remind me to rebuild and redeploy.
Catch it before your users do
A break like this is easy to miss because the site still loads and your own session may keep working. Scheduled testing from FlowCanary is launching by 30 November 2026. Once it is live, it will test the flows a new visitor can do in your app, such as sign-up and checkout, in a real browser on a schedule, with logged-in flows on Pro, and tell you in plain English when one breaks, with a fix prompt for Lovable, Bolt, Cursor or Replit. Until then, the free check works today: paste your live URL and it opens the page in a real browser and reports JavaScript errors, failed requests and blank pages.
Sources
- Supabase: API keys
- Supabase: Migrating to publishable and secret API keys
- Supabase: Rotate a leaked or compromised API key
- Vite: Env variables and modes
- Next.js: Environment variables