API key exposed in your Lovable or Bolt app? How to check and fix it (2026)
Prices and facts checked on each tool's official site. Plans change often, so confirm before you pay.
"Why is the API key in the frontend?" is one of the most common things people find in AI-built apps. Builders like Lovable and Bolt make a web app that runs in your visitor's browser, and anything the browser downloads, anyone can read. That's fine for some keys and a disaster for others. In February 2026 one founder's AI-written app shipped its Stripe secret key in the page code; attackers used it to charge 175 of his customers $500 each, and even after Stripe reversed the charges he lost about $2,500 in fees. Here's how to check your own app in about 3 minutes, which keys are fine to show, and what to do if you find one that isn't.
Quick answer
Open your live site, open DevTools, and search all of the page's files for sk_live_, sb_secret_, sk-proj- and InNlcnZpY2Vfcm9sZS (how a legacy Supabase service_role key looks inside its text). If anything turns up, assume the key is leaked: make a new key at the service first, store it in Lovable's or Bolt's Secrets (never in a VITE_ variable), have the AI move that call into a server function, then delete or expire the old key. Publishable keys (sb_publishable_, the legacy anon key, pk_live_) are meant to be public, so finding those is normal.
Which keys are OK to show, and which aren't
| Key | Starts with | OK in the browser? |
|---|---|---|
| Supabase publishable key | sb_publishable_ | Yes. It only reaches what your row level security policies allow. |
| Supabase legacy anon key | eyJ... (role anon) | Yes, same as publishable. Supabase is retiring the legacy keys by the end of 2026. |
| Stripe publishable key | pk_live_ / pk_test_ | Yes. It can't create charges or read your account. |
| Supabase secret key | sb_secret_ | No. Full access to your data, skipping every RLS rule. |
| Supabase legacy service_role key | eyJ... (role service_role) | No. Same power as the secret key. |
| Stripe secret or restricted key | sk_live_ / rk_live_ | No. Can charge saved cards, issue refunds and read customer data. |
| OpenAI / Anthropic key | sk-proj- / sk-ant- | No. Anyone can run up your AI bill. |
| Email service key (Resend and others) | varies, e.g. re_ | No. Lets strangers send email as you. |
The rule from Supabase's docs: if the code ships to users (a web page or phone app), only the publishable key belongs there. If the code runs somewhere you control (a server or Edge Function), that's where secret keys go.
The 3-minute check (no tools to install)
- Open your published site in Chrome, not the builder preview. The live site is what strangers see.
- Open DevTools:
Cmd + Option + Ion Mac,Ctrl + Shift + Ion Windows. - Open the search across all files:
Cmd + Option + Fon Mac,Ctrl + Shift + Fon Windows. - Search one at a time for:
sk_live_,rk_live_,sb_secret_,InNlcnZpY2Vfcm9sZS,sk-proj-,sk-ant-. Also trysk_test_: a test key can't move real money, but it shows the AI wired payments in the wrong place. - Click around the app (sign in, open the pages that use AI or payments) and search again, because some code only loads when you visit that page.
Zero results for all of them is a good sign. It doesn't prove the app is safe: an open database table or a server function anyone can call can leak data without any key showing. For that, see our 2-minute check for data readable without login.
Found one? Fix it in this order
- Make a new key at the service. Stripe: Developers, API keys, then Rotate key on the leaked key, and set the old one's expiry to Now (otherwise Stripe keeps the old key working for up to 7 days). Supabase: Settings, API Keys, create a new secret key. OpenAI: the API keys page in the platform dashboard.
- Put the new key in Secrets, not in the code. In Lovable it's More, Settings, Secrets (or let Lovable ask for it in chat). In Bolt it's the database icon, then Secrets. Both keep the value on the server; it never reaches the browser.
- Move the call to the server. Ask the AI to make the request from an Edge Function (Lovable) or server function (Bolt) that reads the secret, and have the page call that function instead.
- Delete or expire the old key once the app works with the new one. For a legacy Supabase service_role key, Supabase's steps are to switch the browser to the publishable key and deactivate the legacy keys, since you can't delete just the one.
- Check the damage. Look at Stripe's payments and request logs, your OpenAI usage page and your Supabase tables for anything you didn't do. If you see unauthorised charges, contact Stripe support straight away.
Don't skip step 1. Moving the old key out of the code doesn't help, because anyone who already copied it can keep using it. And if your project syncs to a public GitHub repo, the old key is still in its history even after you delete it from the code.
What to paste into Lovable or Bolt
Copy this into the chat, changing the service name:
My Stripe secret key is in the frontend code. Move every call that uses it into a server function (Edge Function) that reads STRIPE_SECRET_KEY from Secrets, and have the page call that function instead. Remove the key and any VITE_ variable holding it from the code and .env. Only the publishable key may stay in the frontend. Then list every API key or secret the frontend still uses and say whether each one is safe to be public.
Then publish again (Lovable: Publish, then Publish changes; Bolt: Publish, then Update) and repeat the 3-minute check on the live site. Lovable also has a Deep security scan that looks for leaked secrets in your code, worth running after the fix.
Why AI builders put keys in the wrong place
The fastest way to make a feature "work" is often to call Stripe or OpenAI straight from the page with the key pasted in. It runs, nothing errors, and nothing warns you. The usual trap is a VITE_ variable: Vite puts every VITE_ value into the JavaScript visitors download, so VITE_STRIPE_SECRET_KEY or VITE_OPENAI_API_KEY is public by design. Lovable now spots API keys pasted into chat and steers you to Secrets, and Bolt asks you to add keys as secrets, but keys can still end up in code from older projects, pasted snippets, or a fix the AI made in a hurry.
When it's time to get help
Often this is one key and one function to move. Get a second pair of eyes when:
- You found a secret key and don't know what else might be exposed.
- Your app takes payments or stores personal data.
- The AI moved the key but the feature broke, or the key keeps coming back.
- You're about to launch and want the whole app checked, not just one key.
| Option | Price | What you get |
|---|---|---|
| App Audit | $49 one-time | A plain-English written list of exposed keys, open database tables and other risks, with how to fix each one, within 3 business days |
| Payments Live | $199 one-time | Stripe payments wired through a server function the right way and tested before going live |
| Launch Pack | $499 one-time | Agreed bug fixes, Stripe payments, and your app published on your own domain with HTTPS |
We confirm the scope by email before any work starts, and you can ask questions first without paying. Never send anyone your secret keys or passwords, us included; see how to give a developer access safely.
Not sure your builder was the right pick in the first place? Our free 20-second tool matcher suggests one for your idea.
Related guides
- Worried about data readable without login? Run the Lovable email-leak check.
- Launching a Lovable app? Use the Lovable + Supabase launch checklist.
- Adding payments the right way? See Stripe payments in a Bolt app or Stripe in a Lovable app.
- New table won't save after the fix? See Supabase "permission denied for table".
Sources
- Supabase: API keys (publishable vs secret, which key goes where, legacy keys retired by end of 2026)
- Supabase: rotate a leaked or compromised API key
- Stripe: API keys (key types, rotate key, 7-day grace period)
- OpenAI: best practices for API key safety (never deploy your key in browsers)
- Lovable: Secrets (Secrets vs VITE_ variables, More, Settings, Secrets)
- Lovable: security overview (key detection in chat, Deep scan for leaked secrets)
- Bolt: Secrets (secrets only reach server functions, .env values can reach the browser)
- Awesome Agents: founder loses $2,500 after AI-coded app leaks Stripe keys (Feb 2026 incident)
FAQ
Which API keys are safe to have in my app's frontend?
Only keys made to be public: the Supabase publishable key (sb_publishable_...) or the legacy anon key, the Supabase project URL, and the Stripe publishable key (pk_live_ or pk_test_). Your database rules (row level security) are what protect your data, not hiding those keys.
Which keys must never be in the browser?
Stripe secret and restricted keys (sk_live_, rk_live_), the Supabase secret key (sb_secret_...) or legacy service_role key, AI provider keys like OpenAI (sk-proj-...) or Anthropic (sk-ant-...), email service keys like Resend, and any webhook signing secret. Anyone who visits your site can read whatever the browser downloads.
I moved the key to Secrets. Am I safe now?
Not yet. If a secret key was ever in your live site or a public GitHub repo, treat it as leaked: create a new key at the service, put the new one in Secrets, then delete or expire the old one. Moving the old key only hides it from new visitors; anyone who already copied it can still use it.
Is a VITE_ environment variable private?
No. Lovable and Bolt apps are built with Vite, and Vite puts every VITE_-prefixed value into the JavaScript that visitors download. Use VITE_ only for public values. Secret keys go in Lovable's Secrets or Bolt's Secrets, where only server functions can read them.
When should I pay someone to check my app?
If you found a secret key and aren't sure what else is exposed, if your app takes payments or stores personal data, or before you launch. StackMatch's App Audit is $49 for a plain-English written list of exposed keys, open database tables and other risks, with how to fix each one.
Some links are referral links; we may earn a commission at no extra cost to you. It never changes our recommendations.