v0: API keys in front-end code
Anything in your front-end code is downloaded by every visitor. Keys for OpenAI, Stripe secret keys, email services and similar must live on a server.
Free scan: check my app Just your web address. Results in seconds. No signup, no card.
Why it matters for your v0 app
v0 builds Next.js apps that are often deployed on Vercel. Server code is safer, but anything with NEXT_PUBLIC_ in its name is sent to the browser.
Someone copies your key and runs up your bill, sends email as you, or reads your payment data.
How to check in five minutes
- On your live site press F12 and search the loaded files for “sk-”, “sk_live”, “key” and “secret”.
- Check any variable starting with VITE_, NEXT_PUBLIC_ or REACT_APP_. These are public by design.
- Rotate any secret you find, then move it.
What PeekLok’s scan checks
PeekLok’s scan searches your page and the scripts it loads from your own site for common secret key formats: OpenAI, Anthropic, Stripe live secret, AWS, GitHub and Google API keys, plus private key blocks. It can’t recognise every kind of key, so still do the check above.
Fix prompt to paste into the v0 chat
Find every secret API key used in front-end code, including any VITE_, NEXT_PUBLIC_ or REACT_APP_ variable that holds a secret. Move each call that needs a secret into a server function, store the key as a server secret, and have the front end call that function instead. List the keys I must rotate. (This is a v0 app using Supabase or Neon. Keep secrets in Vercel environment variables (without NEXT_PUBLIC_).)
After the AI makes changes, test again with two accounts. AI fixes can look right and still miss a table or route.
Sources
Related
- v0: Supabase RLS turned off
- v0: Exposed anon or service role key
- v0: Open database tables
- v0: Missing auth on endpoints
- v0: Missing security headers
- v0: One customer can see another’s data
Same issue in other builders:
All v0 security guides · API keys in front-end code explained
Get a free scan
PeekLok checks your live app for secret keys in the page code, a Supabase service or anon key showing, Supabase tables anyone can read with the public key, and five browser security headers. If your app uses Supabase login, you can add two test logins and it checks whether one user can see the other’s data. Only scan apps you own. First scan free. Weekly re-checks will be $12 US a month once payments open.
