🐕 LatchDog

← Guides

Exposed API keys in JavaScript bundles: what AI builders leak and how to fix it

Everything in your frontend bundle is public. Env vars prefixed VITE_, NEXT_PUBLIC_ or REACT_APP_ are compiled into the JavaScript every visitor downloads, and source maps can expose even more.

Safe in the browser

Never in the browser

Fix

Move the call into a server-side function (Supabase Edge Function, API route, Cloudflare Worker) that reads the key from a server-only secret. Then rotate the leaked key: create a new one, deploy it, and only then revoke the old one.

Check your app now

Free, read-only public check: no sign-up, no card. Headers and HTTPS only. Deep scan (leaked keys, open Supabase tables, .env/.git) after you verify you own the domain.