For Lovable, Bolt, Cursor and v0 apps
Leaked your Anthropic API key? Do this, in order
Direct answer
If your Anthropic key (it starts with sk-ant-) is in your frontend JavaScript, anyone who opens your site can copy it and make requests billed to your account. Delete it in the Claude Console and create a new one, check your usage, set a monthly spend limit, and move the Claude API call into a server function so the new key never reaches the browser.
LeakLatch is a free, read-only scan of a live URL you own. It reports leaked secret keys in your JS bundles, Supabase tables that answer with your public anon key, and missing security headers. You get a risk score, redacted findings, and a fix prompt for Lovable, Cursor, or Claude.
What to do
Five steps for your own project
Use these on a project you own. The commands only read your own files; nothing here changes your app. Sources for Anthropic's guidance: What should I do if I suspect my API key has been compromised?, API key best practices, and Authentication (Claude API docs).
Step 1
Delete the leaked key first
Open the API keys page in the Claude Console (platform.claude.com/settings/keys), open the menu next to the leaked key, and choose Delete API key. Anthropic's own guidance is to revoke a key immediately if you believe it leaked, then click Create key to make a replacement and store it in a secrets manager, not in version control. Until the old key is deleted, anyone with a copy can keep using it.
Step 2
Check usage and set a spend limit
Look at the Usage page in the Claude Console for traffic you do not recognise, including breakdowns by API key. You can set your own monthly spend limit under Spend limits; when that limit is reached, API requests are rejected until you raise or remove it. If you continue to see suspicious activity, contact Anthropic Support.
Step 3
Move the Anthropic call to a server function
Anthropic says 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 key in that page's code. In a vibe-coded app that means a Supabase Edge Function, a Vercel or Netlify function, or a Next.js route handler that holds the key and calls Anthropic for the browser.
Step 4
Store the new key in a server-only variable
Anything with a VITE_ or NEXT_PUBLIC_ prefix is copied into the JavaScript every visitor downloads. Put the new key in a variable without those prefixes (for example ANTHROPIC_API_KEY) in your hosting or Supabase secrets settings, and never in the frontend code or a committed .env file. Anthropic also recommends separate keys for development, testing, and production.
Step 5
Rebuild and check the live site
Old bundles can stay cached, and your hosting dashboard can hold different values than your local .env. After redeploying, search the build output with the commands below, then check the live URL to confirm no sk-ant- key ships to visitors.
# Run in your own project folder after a production build.
# Vite (Lovable, Bolt): output in dist/ Next.js (Cursor, v0): output in .next/static/
# 1. Anthropic-style keys (sk-ant-...). Prints only a short prefix.
grep -rEoh "sk-ant-[A-Za-z0-9_-]{6}" dist .next/static 2>/dev/null | sort -u
# 2. Where your code talks to Anthropic directly from the client:
grep -rnE "api\.anthropic\.com|new Anthropic\(|ANTHROPIC_API_KEY" src app 2>/dev/null
# 3. Public env variables that hold an Anthropic key (these are built into the bundle):
grep -rnE "(VITE_|NEXT_PUBLIC_)[A-Z_]*ANTHROPIC" . --include=*.env* --include=*.ts --include=*.tsx --include=*.js 2>/dev/nullCopy-paste fix
Move the Anthropic call server-side with one prompt
Paste this into Lovable, Cursor, or Claude and point it at your own project. Review each change before you apply it, and delete the old key if it already shipped.
You are helping me remove the Anthropic API key from the client side of my own app. Keep existing features working. 1. Find every place the app calls Anthropic (api.anthropic.com, the Anthropic SDK, ANTHROPIC_API_KEY) and every env var or hard-coded string that holds an Anthropic key (sk-ant-...), including VITE_ and NEXT_PUBLIC_ variables. 2. Move each Anthropic call into a server function (Supabase Edge Function, Vercel/Netlify function, or Next.js route handler) that reads the key from a server-only env var named ANTHROPIC_API_KEY with no VITE_ or NEXT_PUBLIC_ prefix. 3. In that function, check the caller is signed in or otherwise allowed, validate the input, and add a simple per-user rate limit. 4. Change the frontend to call my server function instead of Anthropic directly. 5. Remove the key from the frontend and committed files, rebuild, confirm no sk-ant- string is in the build output, and remind me to delete the old key in the Claude Console (platform.claude.com/settings/keys) and set a monthly spend limit.
FAQ
Straight answers about a leaked Anthropic key
Is it safe to put my Anthropic API key in the frontend if the app is private or behind a login?
No. A login screen does not hide your JavaScript files; the bundle is downloaded before or alongside the login, and anyone can open it in the browser's developer tools. Anthropic's authentication docs say to call the Claude API from your own back end, because anyone who uses a webpage can read an API key in that page's code.
What can someone do with my leaked Anthropic key?
They can send API requests that are billed to your account. Anthropic's help center compares an API key to a credit card number: if someone obtains and uses it, they incur charges on your behalf.
Is deleting the key from my code enough?
No. Copies of the old bundle, git history, and forks still contain the key, and it keeps working until you delete it in the Claude Console. Delete and replace it first, then clean up the code.
How do I call Anthropic from a Lovable or Bolt app without exposing the key?
Create a server function (for example a Supabase Edge Function) that reads the key from a server-side secret, checks that the caller is allowed, and calls the Claude API. Your frontend calls that function instead of api.anthropic.com. Adding a per-user rate limit in the function also limits abuse of your own endpoint.
What does LeakLatch check here?
LeakLatch loads the live URL you give it and its JavaScript bundles, read-only, and looks for known secret key patterns, including Anthropic sk-ant- keys, plus OpenAI, Stripe, AWS, Resend, GitHub and Supabase service_role keys. It also checks whether Supabase tables answer with your public anon key. Secret values are redacted in the report. You must confirm you own the site or have permission to scan it.
Is this a substitute for a full security audit?
No. LeakLatch is a pre-ship check for leaked secrets, open Supabase tables, and basic headers. It does not replace a penetration test or a careful code review.
Want this check done for you, read-only?
Paste a URL you own. LeakLatch returns a score, redacted findings, and a fix prompt.
Scan my site free