greenlıt

Guide · Keys

I leaked an API key in my frontend. What now?

Everything in your website's JavaScript is public. If a secret key ended up there, anyone can open the browser's developer tools and copy it, and bots scan for exactly this. Here is what to do, in order.

Updated 18 November 2026

1. Rotate the key first

Do this before anything else. Deleting the key from your code does not help: it has already been served to visitors, cached, and possibly copied. The only fix is to make the old key stop working.

2. Check whether someone already used it

3. Move the call to a server

A secret key belongs on a server your users can't see. The frontend asks your server, the server calls the API with the key. With Supabase, the usual place is an Edge Function:

supabase secrets set STRIPE_SECRET_KEY=sk_live_...

Then read it inside the function with Deno.env.get("STRIPE_SECRET_KEY"), and call the function from your app. If you build with Lovable or Bolt, you can ask for exactly this: "Move every call that uses the Stripe secret key into a Supabase Edge Function, read the key from a secret, and remove it from the client."

Watch the names of your environment variables. Anything starting with VITE_, NEXT_PUBLIC_, EXPO_PUBLIC_, REACT_APP_ or PUBLIC_ is put into the browser bundle on purpose. A secret key must never have one of those prefixes.

4. Clean up the rest

Which keys are meant to be public?

Not every key in the browser is a leak. These are designed to be there, and are protected another way:

5. Check again

After the fix is live, check the site from the outside to confirm the key is gone from what visitors get. Greenlit recognises 32 kinds of secret keys in the JavaScript your site sends, and tells you which ones are serious.

Find out what your site gives away

Paste your app's address. Greenlit reads only what any visitor's browser gets, grades it from A to F, and writes a fix prompt for each problem. Free, no sign-up.

Check your app

More guides