Skip to content
ShipCheck
Guides

Your Anthropic API key is in the frontend: how to find it, delete it and move the Claude call server-side

Updated 3 December 2026

If your Lovable, Bolt, v0 or Vite app talks to Claude from the browser, the Anthropic API key is in the JavaScript that every visitor downloads. That is already a leak, even if the app only has a handful of users. Anthropic's docs say to call the Claude API from your own back end, not from code that runs in your users' browsers, because anyone who uses the page can read a credential in that page's code. This guide is the Anthropic-specific version of that check: how to confirm the key is in the live bundle, what to do first, and where the call should live instead.

Check your own app for this, free.

Paste your live URL. ShipCheck looks for leaked API keys in your page and JavaScript, exposed files like /.env and /.git, missing security headers, SSL certificate problems, domain expiry (custom domains only) and what Google sees without running JavaScript. You'll see your score without signing up.

See an example report

Short answer

An Anthropic API key must never ship in the frontend. That includes Developer API keys that start with sk-ant-api… and Admin API keys that start with sk-ant-admin…. Putting one in VITE_ANTHROPIC_API_KEY or NEXT_PUBLIC_ANTHROPIC_API_KEY does not hide it: Vite and Next.js copy those values into the public bundle at build time. If you find one, delete it first in the Claude Console, then move the Claude call into a server function and store the replacement key only as a server-side secret. A key prefix check (nothing leaves your browser) will tell you whether the string starts like an Anthropic secret. For the OpenAI version of this problem, see OpenAI keys in the frontend. For the same check across other providers, see how to check for leaked API keys.

How to check the live app

Check the deployed URL, not only the editor preview.

  1. Search the JavaScript. Open the live site, press F12, go to Sources, and search all files (Ctrl+Shift+F, or Cmd+Option+F on a Mac) for sk-ant- and api.anthropic.com. Click the chat or AI feature first, because some chunks only load then.
  2. Watch the Network tab. Use the AI feature. If the browser sends a request straight to api.anthropic.com with an x-api-key header or an Authorization: Bearer … header, the secret key is in the frontend, even if the text search missed it. The TypeScript SDK also sends anthropic-dangerous-direct-browser-access: true when browser use is enabled; seeing that header is another sign the call is coming from the page, not your server.
  3. Or grep the scripts linked from the page:
    URL=https://your-app.com
    for js in $(curl -s "$URL" \
      | grep -oE 'src="[^"]+\.js[^"]*"' | cut -d'"' -f2); do
      case "$js" in http*) u="$js";; /*) u="$URL$js";; *) u="$URL/$js";; esac
      curl -s "$u" | grep -oE 'sk-ant-(api|admin)[0-9]{2}-[A-Za-z0-9_-]{8,}' \
        | cut -c1-16 | sort -u
    done

    This prints only the start of a match, so you are not pasting a full key into your terminal history. A clean result is not proof: it only covers scripts linked from the HTML, not code that loads later.

Not sure what you found? Type just the first few characters into the is this key safe? tool. Do not paste the whole key.

Why this happens in vibe-coded apps

The usual prompt is “add Claude to my app” plus a key in an environment variable. Frontend build tools then bake any public-prefixed variable into the JavaScript:

  • Vite (most Lovable and Bolt apps): variables starting with VITE_ are exposed in client-side source after the build. Vite's docs say VITE_* variables should not contain sensitive information such as API keys, and recommend a backend or serverless/edge function for secrets. See Vite: Env Variables and Modes.
  • Next.js (v0, many Cursor apps): variables starting with NEXT_PUBLIC_ are inlined into the client bundle at build time. A variable named ANTHROPIC_API_KEY, without that prefix, stays on the server. See Next.js environment variables.

The official TypeScript SDK can also send requests from a browser if you set dangerouslyAllowBrowser to true (it then adds the anthropic-dangerous-direct-browser-access header). That flag does not make the key safe. Anthropic's authentication docs still say to call Claude from your own back end, because anyone who uses the page can read the credential. Some organisation settings, including zero data retention, block those browser requests anyway and return a 401. See Authentication.

Renaming the variable, splitting the key, or “hiding” it in a client helper does not help. The browser has to send the real key to Anthropic, so anyone can copy it from the Network tab.

If the key already leaked, do this in order

  1. Delete the exposed key first. Pausing or taking down the app does not stop anyone: the key works without your site. In the Claude Console, open the API keys page, open the menu (three dots) next to the key, and choose Delete API key. If you do not see it, check each Workspace on that page, and any other Console organisation you belong to. Disable can be turned back on later; Delete is permanent. Anthropic recommends deleting a key you think has leaked, then creating a replacement and storing it in a secrets manager, not in version control (If you suspect your API key has been compromised).
  2. Do not wait for GitHub to catch it. Anthropic has a partnership with GitHub's secret scanning: if a Claude API key appears in a public GitHub repository, GitHub notifies Anthropic and Anthropic deactivates the key and emails you. If you get that email, delete the key instead of turning it back on, create a new one, and update the apps that used it (API key best practices). A key sitting in a published Lovable, Bolt or Vercel frontend is not the same thing as a public GitHub repo. That automatic deactivation may never run. Delete the key yourself.
  3. Review usage, then contact support if you see misuse. Check the Usage and Logs pages for unexpected models, volume or start times. Anthropic also recommends setting spend limits on the Billing page if your organisation has them, and being careful with auto-reload limits, because both a leaked key and a runaway script can drive unexpected usage. Anthropic does not promise a refund.
  4. Create a replacement and keep it on the server (next section). When you create the new key you can set an expiration (presets include 3 hours, 1 day, 7 days or 30 days, or a custom date, or never). You cannot change the expiration later (Developer API keys). If you paste the new key into a VITE_ or NEXT_PUBLIC_ variable, it will leak the same way. Redeploy after you move the call, then confirm in the Console that the old key is deleted. Requests made with a deleted or expired key return a 401 authentication_error.

If other secrets were in the same frontend or the same host incident, rotate those too, in priority order: which keys to rotate, and in what order.

The fix: the browser calls your function, not Claude

Anthropic's guidance is to call the Claude API from your own back end, which holds the credential and calls the API. Typically the web front end calls that back end, not api.anthropic.com directly (Browser-based applications).

  • Lovable or Bolt with Supabase: put the call in a Supabase Edge Function and store the key as a secret (Edge Functions → Secrets, or supabase secrets set ANTHROPIC_API_KEY=…). The function reads it with Deno.env.get("ANTHROPIC_API_KEY").
  • Next.js (v0, Cursor): use a Route Handler or Server Action and read process.env.ANTHROPIC_API_KEY — a variable without the NEXT_PUBLIC_ prefix, set in your host's environment settings.
  • Anything else: a serverless or edge function on your host (Vercel, Netlify, Cloudflare) works the same way.

Then protect that function, or strangers will call it as a free proxy: require a signed-in user, add a per-user rate limit, choose the model and cap output tokens on the server instead of trusting the browser, and keep a spend limit in the Claude Console as a backstop where your organisation supports one. Leave dangerouslyAllowBrowser off for a public web app.

An Admin API key (the kind that starts with sk-ant-admin…) cannot call Claude, but it can manage and report on an organisation. It is still a secret and must stay off the frontend too.

What ShipCheck checks (and what it doesn't)

The free scan fetches the raw HTML of your live URL and the same-origin JavaScript files linked from that HTML (and public source maps from those files, when they are available). It does not run JavaScript or click around the app. It flags an Anthropic API key that matches sk-ant-api… or sk-ant-admin… in that HTML or those files as a critical finding. A key that only appears in a chunk loaded after you use a feature can be missed, so also use the DevTools and Network checks above. The scan does not call Anthropic with the key, does not delete or disable it, and does not check your usage or spend limits. It does not probe Storage buckets, and it does not detect Next.js versions. The Supabase table-read test needs a free account that has verified it owns the app; the anonymous scan does not query tables. Paid plans re-scan weekly on Solo ($12/mo) or daily on Builder ($29/mo). Separately, paid plans also check once a day that the app URL returns a status below 400 (a 15 second timeout, with an email after two failed checks). That daily check is not a secrets test.

FAQ

Is VITE_ANTHROPIC_API_KEY safe in a Lovable or Bolt app?

No. Vite exposes any VITE_ variable in the client bundle at build time, and Vite's own docs say those variables should not contain API keys. Store ANTHROPIC_API_KEY as a server secret and call Claude from a Supabase Edge Function or another server function.

Does dangerouslyAllowBrowser make it safe to put the key in the frontend?

No. That TypeScript SDK flag only lets the browser send a request to the Claude API. Anthropic's docs still say to call Claude from your own back end, because anyone who uses the page can read the credential. Some organisations also block those browser requests and return a 401.

Will GitHub or Anthropic automatically deactivate a key that leaked in my live app?

Only if the key appears in a public GitHub repository, where GitHub's secret scanning can notify Anthropic. A key in a published Lovable, Bolt or Vercel frontend may never be found that way. Delete the key yourself in the Claude Console, then create a replacement and keep it on the server.

The app only has a few users, or it is still on a preview URL. Does that matter?

No. Anyone who can load the URL can download the JavaScript and copy the key. The risk is a stranger spending on your Anthropic account, not your current user count.

Does ShipCheck check for Anthropic keys?

Yes. The free scan searches the live HTML and the same-origin JavaScript linked from that page (plus public source maps it finds) and flags a matching sk-ant-api… or sk-ant-admin… key as critical. It does not run JavaScript, so also search in DevTools if a feature loads code later. It will not delete the key for you.

Run the same checks on your app.

A free scan takes under a minute. No card, and no sign-up to see your score and the list of issues.

See an example report