Skip to content
ShipCheck
Guides

How to check your vibe-coded app for leaked API keys (and which keys are safe in the frontend)

Updated 13 November 2026

To check a vibe-coded app for leaked API keys, open the live site and search the JavaScript for secret prefixes (sk_live, sk-, service_role, sb_secret_, AKIA). Confirm that anything you find is meant to be public. A secret key in the frontend is already public, even if the app only has a few users. This guide covers that 5-minute check, which keys are safe in the browser, and what to do, in order, if one has leaked.

Check your own app for this, free.

Paste your live URL. ShipCheck looks for leaked API keys in your page and JavaScript, exposed files like /.env and /.git, missing security headers, SSL certificate problems, domain expiry (custom domains only) and what Google sees without running JavaScript. You'll see your score without signing up.

See an example report

Short answer

Not if it's a secret key. Everything your frontend uses is downloaded by every visitor, so anyone can read it in DevTools. That doesn't depend on how many users you have. Bots scan public websites and GitHub repos for strings that look like keys, and they find small apps as easily as big ones. The risk isn't your 3 users. It's a stranger spending your credits.

Some keys, though, are designed to be public. The question is which kind you have.

Fine in the frontend (public by design)Never in the frontend (secret)
Supabase anon / publishable key (sb_publishable_…), if Row Level Security is set up properlySupabase service_role or secret key (sb_secret_…): it bypasses RLS completely
Stripe publishable key (pk_live_…)Stripe secret or restricted key (sk_live_…, rk_live_…; see publishable vs secret)
Firebase web config, if your security rules are locked down (see Firebase security rules)OpenAI (sk-…, sk-proj-…; see OpenAI keys in the frontend), Anthropic (sk-ant-…; see Anthropic keys in the frontend), OpenRouter (sk-or-v1-…), Groq, Replicate, Hugging Face
Google Maps / Firebase browser keys (AIza…), if restricted to your domain and the APIs you useAWS access keys, GitHub tokens (see GitHub tokens in the frontend), email API keys (Resend, SendGrid, Mailgun), database URLs with a password

Rule of thumb: if the provider calls it a secret key, or the key can spend money, send email or read private data on its own, it belongs on a server. For the Supabase side of this, see is the Supabase anon key safe?

Not sure which kind yours is? Type just its first few characters into the key prefix checker. Nothing you type leaves your browser.

"But it's in an environment variable"

Environment variables only keep a key secret if they stay on the server. Frontend build tools deliberately copy variables with a public prefix into the JavaScript bundle at build time:

  • Vite (most Lovable and Bolt apps): anything starting with VITE_. Vite's own docs say these variables should not contain API keys.
  • Next.js (v0, many Cursor apps): anything starting with NEXT_PUBLIC_.
  • Create React App: REACT_APP_. Expo: EXPO_PUBLIC_.

Hiding the key doesn't help either. Base64, splitting it into pieces or "obfuscating" it fails because the browser has to put the real key in the request, and anyone can copy it from the DevTools Network tab.

Check your live app in 5 minutes

Check the deployed site, not your editor preview. That's what attackers see.

1. Search the JavaScript in DevTools

Open your live site, press F12, go to Sources, and use search across all files (Ctrl+Shift+F, or Cmd+Option+F on a Mac). Search for: sk-, sk_live, sk-ant-, sk-or-v1, service_role, sb_secret_, AKIA, ghp_, github_pat_. Click around the app first, because some code only loads when you open that feature.

2. Watch the Network tab

In DevTools → Network, use your AI or payments feature. If your browser sends requests straight to api.openai.com, api.anthropic.com, openrouter.ai, api.stripe.com or api.github.com with an Authorization header, the secret key is in your frontend, even if your text search missed it.

3. Or grep the bundles from a terminal

URL=https://your-app.com
for js in $(curl -s "$URL" | grep -oE 'src="[^"]+\.js[^"]*"' | cut -d'"' -f2); do
  case "$js" in http*) u="$js";; /*) u="$URL$js";; *) u="$URL/$js";; esac
  curl -s "$u" | grep -oE 'sk-(proj-|ant-|or-v1-)?[A-Za-z0-9_-]{20,}|sk_live_[0-9a-zA-Z]{20,}|sb_secret_[A-Za-z0-9_-]{20,}|AKIA[0-9A-Z]{16}' | cut -c1-14 | sort -u
done

This prints only the start of anything that looks like a key. It only checks scripts linked directly from the page HTML, so a clean result here isn't proof; the DevTools search covers code that loads later.

4. Check your repo history

If your code is (or ever was) on GitHub, deleting a key in a later commit doesn't remove it from history. Search every commit:

git log -p -S "sk-" --all | grep -oE 'sk-[A-Za-z0-9_-]{6}' | sort -u

On GitHub, secret scanning alerts (repo → Security) also list keys found in your history.

If a key leaked: do this, in order

  1. Revoke the key first, before you fix the code. Pausing or taking down your app doesn't stop anyone. The key works without your app. In OpenAI, go to the API keys page and revoke or delete it. In OpenRouter, open Keys and delete or disable it. In Anthropic's Console, open API keys and delete or disable it. For Stripe, roll the secret key in the Developers → API keys section.
  2. Create a replacement with limits. OpenRouter lets you set a credit limit on each key (and recommends one on every key). In OpenAI, set a monthly spend limit for your project with hard enforcement turned on, because OpenAI's docs note that spend alerts on their own don't stop traffic. OpenAI project keys can also be given an expiry date.
  3. Put the new key somewhere server-side only (see the next section). If you paste it back where the old one was, it will leak the same way.
  4. Check the damage. Look at the usage or activity pages to see when the strange usage started, which models were used and how much. The start date usually points at the cause: the day you deployed a feature, made a repo public, or used a host that had an incident.
  5. Contact the provider's support with the dates, the models used and the key name. OpenAI's help centre asks you to contact them through help.openai.com if you're worried about misuse. No provider promises a refund, but it's worth asking about clearly fraudulent usage.
  6. Find how it got out. The usual causes: the frontend bundle, a public GitHub repo (even one old commit), a hosting provider's environment variables after a security incident, or a key pasted into a screenshot, chat, browser extension or online tool. If your host had an incident, rotate every secret stored there, not just the one you noticed.
  7. Confirm the old key is dead. It should now return 401:
    curl -s -o /dev/null -w "%{http_code}\n" https://api.openai.com/v1/models -H "Authorization: Bearer OLD_KEY"
    curl -s -o /dev/null -w "%{http_code}\n" https://openrouter.ai/api/v1/key -H "Authorization: Bearer OLD_KEY"

Leaked a Supabase service_role or secret key? Treat it the same way: rotate it in Supabase (Project Settings → API Keys; for legacy JWT keys, rotate the JWT secret), because anyone holding it can read, change or delete every row in your database.

The fix: call the API from a server function

The pattern is the same on every platform: the browser calls your function, and only your function knows the key.

  • Lovable or Bolt with Supabase: put the call in a Supabase Edge Function and store the key as a secret (in the Supabase dashboard under Edge Functions → Secrets, or supabase secrets set OPENAI_API_KEY=…). The function reads it with Deno.env.get("OPENAI_API_KEY").
  • Next.js (v0, Cursor): use a Route Handler or Server Action and read process.env.OPENAI_API_KEY, a variable without the NEXT_PUBLIC_ prefix, set in your host's environment settings.
  • Anything else: a serverless function on your host (Vercel, Netlify, Cloudflare) or a small backend works the same way.

Then protect the function, or people will simply call your function instead of the API: require a signed-in user (check the session or the Supabase JWT in the function), add a per-user rate limit, choose the model and cap max_tokens on the server instead of accepting them from the browser, and keep the provider's spend limit as a backstop.

Copy-paste prompt for your AI builder

Security fix, show me the changes before applying them:
1. Find every place an API key or secret is used in frontend code, including any
   VITE_, NEXT_PUBLIC_, REACT_APP_ or EXPO_PUBLIC_ variable that holds a secret.
2. Move every call to OpenAI, Anthropic, OpenRouter, Stripe (secret key) or any other
   paid API into a server-side function (Supabase Edge Function or API route) that
   reads the key from a server-side secret. The browser must only call that function.
3. In the function: require a signed-in user, add a simple per-user rate limit,
   and set the model and max_tokens on the server, not from the request.
4. List any keys that were exposed so I can revoke and replace them.

Keep it from coming back

With AI builders, a later prompt can move a key back into a component without you noticing. Three cheap habits: a spend limit on every paid API key, GitHub secret scanning and push protection on your repo, and a check of the live site after big changes. ShipCheck's paid plans re-scan automatically, weekly (Solo, $12/mo) or daily (Builder, $29/mo), and email you what's new, fixed and still open, with a fix prompt for each issue.

FAQ

Is it OK to put an API key in the frontend if my app only has a few users?

No, not if it's a secret key. Anyone who opens your site can copy it from DevTools, and bots scan public sites and repos for key formats regardless of traffic. The cost comes from strangers using your key, not from your users. Move the call into a server-side function and set a spend limit on the key.

Which API keys are safe to expose in browser code?

Keys designed to be public: the Supabase anon or publishable key (with Row Level Security set up properly), the Stripe publishable key (pk_), the Firebase web config (with locked-down security rules) and Google browser keys restricted to your domain and APIs. Secret keys for OpenAI, Anthropic, OpenRouter, Stripe (sk_ and rk_), the Supabase service_role or secret key, AWS, GitHub and email providers must stay on a server.

Does putting the key in a VITE_ or NEXT_PUBLIC_ environment variable keep it secret?

No. Those prefixes exist to copy the value into the JavaScript sent to every visitor. Only variables without a public prefix, read by server-side code such as an API route or a Supabase Edge Function, stay secret. Encoding or splitting the key doesn't help either, because the browser has to send the real key.

My OpenAI or OpenRouter key leaked. What should I do first?

Revoke or delete the key in the provider's dashboard immediately. Taking your app offline doesn't stop anyone using the key. Then create a replacement with a spend limit, store it server-side only, check the usage page to see when the misuse started, contact the provider's support with the details, and find how it leaked before it happens again.

Will the provider refund charges from a leaked key?

No provider guarantees it. Contact support quickly with the dates, models and key name, and say the usage was fraudulent. Spend limits are the reliable protection: OpenRouter supports a credit limit per key, and OpenAI supports project spend limits with hard enforcement.

Can ShipCheck find leaked keys in my app?

Yes, on the public side. The free scan fetches the URL you enter and up to 20 same-origin JavaScript files linked from it, plus their source maps if they're public, and matches known secret key formats including OpenAI, Anthropic, OpenRouter, Groq, Stripe secret keys, Supabase service_role and secret keys, AWS and GitHub. It can't see your repository, your server's environment variables or scripts that are only loaded later, so also search your repo history.

Run the same checks on your app.

A free scan takes under a minute. No card, and no sign-up to see your score and the list of issues.

See an example report