Everything in the browser is public
Your website's JavaScript is downloaded by every visitor. Anyone can open developer tools, search the files and copy what they find. If a secret API key is in there, it is not secret.
Publishable vs secret keys
Some keys are designed to be public:
- Stripe publishable keys (
pk_live_...) - Firebase web config and Supabase anon keys — safe only if your database rules are correct; see Firebase and Supabase misconfiguration
- Google Maps keys restricted to your domain
Others must never reach the browser:
- Stripe secret keys (
sk_live_...) - AI provider keys (OpenAI, Anthropic and similar)
- email service keys (SendGrid, Mailgun, Postmark)
- Supabase service role keys, AWS secret keys, database passwords
What happens when a secret key leaks
- AI and SMS keys get used to run up large bills
- email keys get used to send phishing from your domain
- payment keys can be used to issue refunds or read customer data
- cloud keys can expose storage buckets and servers
How to find leaks in your site
- Open your live site, then developer tools → Sources, and search for
key,secret,token,sk_andBearer. - Check build-time environment variables. In many frameworks, variables with a public prefix (
NEXT_PUBLIC_,VITE_,REACT_APP_) are baked into the bundle. - Check source maps — if
.mapfiles are public, your original source is too. - Run a free scan; Yrzo AI looks for common secret patterns in served JavaScript.
How to fix it
- Rotate the leaked key immediately. Removing it from the code is not enough — it is already out.
- Move the call server-side. The browser calls your server; your server calls the API with the secret.
- Restrict what remains public. Lock publishable keys to your domains and minimum permissions.
- Add rate limits to the server endpoints that use paid APIs. See API rate limiting.
- Scan in CI so secrets are caught before deployment.
Our API key security best practices covers storage, rotation and least privilege, and vibe coding security explains why AI-built apps are prone to this.
Check your site
Yrzo AI flags exposed keys, source maps and config files in every report. See plans.
Related reading: Exposed .env Files: Why They Are Dangerous and How to Check Yours · Firebase and Supabase Misconfiguration: How Apps Leak Their Whole Database · React App Security Checklist: Front-End Risks That Matter