cd /news/ai-tools/openai-or-anthropic-api-key-exposed-… · home › topics › ai-tools › article
[ARTICLE · art-164450] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=↓ negative

OpenAI or Anthropic API key exposed in the browser

A developer at Axonscape has flagged a common security flaw in AI-built apps: OpenAI or Anthropic API keys exposed in browser code when clients are created with dangerouslyAllowBrowser or keys are read from VITE_ or NEXT_PUBLIC_ prefixed environment variables, making them readable by any visitor and spendable on the owner's account. The writeup recommends moving all AI calls to a server-side API route that reads the key from a server-only variable, adding a per-user rate limit, and revoking the exposed key. Axonscape's Launchpad offers a free launch check that scans a public GitHub repo or code zip for this and other pre-launch issues without retaining data.

by read1 min views6 publishedNov 5, 2026

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.

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_….

Anything the browser runs, every visitor can read. A public prefix means the value is bundled into the JavaScript everyone downloads.

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.

── more in #ai-tools 4 stories · sorted by recency
── more on @openai 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/openai-or-anthropic-…] indexed:0 read:1min 2026-11-05 · —