An AI client created with dangerouslyAllowBrowser, or a key behind a VITE_ or NEXT_PUBLIC_ prefix, puts your API key in the page, where anyone can copy it and spend on your account.
What you see
The OpenAI or Anthropic client is created in a component, with dangerouslyAllowBrowser: true, or the key is read from VITE_OPENAI_API_KEY or NEXT_PUBLIC_….
Why it happens
Anything the browser runs, every visitor can read. A public prefix means the value is bundled into the JavaScript everyone downloads.
How to fix it
- Revoke the key in the provider's dashboard now: it has already shipped.
- Call the AI from a server route that holds a new key (without a public prefix).
- Have the browser call that route, and limit how often each user can.
Or ask your AI tool to fix it
Paste this into Lovable, Bolt, v0, Replit or Cursor:
The AI API key is exposed in the browser. Move every AI call to a server-side API route that reads the key from a server-only environment variable (no VITE_ or NEXT_PUBLIC_ prefix), have the browser call that route, and add a per-user rate limit. Then tell me to revoke the old key.
The full page, with the request ready to copy, is at launchpad.axonscape.com/fix/ai-api-key-exposed-in-browser. I work on Launchpad by Axonscape, which runs a free launch check for apps built with AI tools: it finds this and the other things that break at launch, from a public GitHub repo or a .zip of the code, and keeps nothing.


