For apps built with Cursor
Is your Cursor app leaking API keys?
Direct answer
Probably not by itself, but often by accident: any key in a NEXT_PUBLIC_ or VITE_ variable, or hard-coded in a client component, is inlined into the JavaScript every visitor downloads, so anyone can read it. The Supabase anon or sb_publishable_ key is meant to be public, but only safe with Row Level Security on every table. OpenAI keys, Stripe secret keys and the Supabase service_role or sb_secret_ key must never ship: rotate any that did and move those calls into an server route or Edge Function.
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 checks for your own project
Use these on a project you own. The commands only read your own files; nothing here changes your app. Sources: Next.js Docs, Environment variables, Vite Docs, Env variables and modes, Supabase Docs, API keys and Cursor Docs, Ignore files.
Step 1
List every NEXT_PUBLIC_ or VITE_ variable
Cursor usually scaffolds Next.js or Vite apps. The Next.js docs say variables prefixed with NEXT_PUBLIC_ are inlined into the JavaScript bundle sent to the browser at build time, and the Vite docs say the same for VITE_ variables. Any API key behind one of those prefixes is readable by anyone who opens your site.
Step 2
Check what the AI wrote into client components
When you ask Cursor to "just make the OpenAI call work", it can put the fetch and the key in a file marked "use client" or in a React component. Search your source for key strings and for provider SDK calls in client files, then search the built output with the commands below.
Step 3
Sort each key: public by design, or secret
Supabase's API keys guide says the publishable key (sb_publishable_) and the legacy anon key are safe to expose, while the secret key (sb_secret_) and legacy service_role key bypass Row Level Security and must stay on a server. OpenAI keys, Stripe sk_live_ keys and AWS secret keys are always secret.
Step 4
Move secret calls into a server route
If a secret key reached the browser, rotate it in the provider's dashboard first. Then move the call into a Next.js Route Handler, Server Action or an Edge Function that reads the key from a variable without the NEXT_PUBLIC_ prefix, and have the browser call your route instead of the provider.
Step 5
Check that Supabase tables are not open to the public key
Even with only the anon key in the bundle, a table without Row Level Security in an exposed schema can be read through the Data API by anyone holding that key. Turn RLS on for every table, scope each policy to the signed-in user, and re-check the live site after each deploy.
# Run in your own project after a production build.
# Next.js puts client JavaScript in .next/static, Vite in dist/
# 1. Which public variables does your code read? Each one is inlined into the bundle.
grep -rEoh "(NEXT_PUBLIC_|VITE_)[A-Z0-9_]+" src app pages 2>/dev/null | sort -u
# 2. Known secret key shapes in the client JavaScript. Prints only the first characters.
grep -rEoh "(sk-(proj-)?[A-Za-z0-9]{4}|sk_live_[A-Za-z0-9]{4}|sb_secret_[A-Za-z0-9_-]{4}|AKIA[A-Z0-9]{4})" .next/static dist 2>/dev/null | sort -u
# 3. Legacy Supabase JWT keys start with eyJ. Decode the middle part and check the
# "role" claim: anon is expected, service_role is a leak.
grep -rEoh "eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}" .next/static dist 2>/dev/null | sort -uCopy-paste fix
Move secrets out of the browser with one prompt
Paste this into Cursor or Claude and point it at your own project. Review each change before you apply it, and rotate any secret key that already shipped.
You are helping me secure my own app built with Cursor. Keep existing features working. 1. List every environment variable the client reads (NEXT_PUBLIC_* or import.meta.env.VITE_*), every hard-coded key string, every file marked "use client" that calls a paid API, and any committed .env file. Only public keys (Supabase anon or sb_publishable_, Stripe pk_) may stay in client code. 2. For each secret key in client code (OpenAI, Stripe sk_, Supabase service_role or sb_secret_, AWS, any other provider), move the code that uses it into a server Route Handler, Server Action or Edge Function that reads the key from a server-only variable without a public prefix. Remind me to rotate each old key. 3. Update the client to call that route instead of the provider directly, with the user's session for auth. 4. List every Supabase table in exposed schemas, enable Row Level Security on any that has it off, and write policies that limit rows to the signed-in user (for example auth.uid() = user_id). 5. Show me each change before applying it, then tell me how to rebuild and confirm no secret key appears in the client build output.
FAQ
Straight answers about Cursor app keys
Does Cursor hide my API keys?
No. Cursor is an editor; what reaches visitors depends on your framework and build. Any key in a NEXT_PUBLIC_ or VITE_ variable, or hard-coded in client code, ends up in the JavaScript the browser downloads. Only code that runs on a server can keep a key private.
Does .cursorignore stop keys from leaking?
No. Cursor's ignore files control which files Cursor's AI features can read, for example to keep a .env file out of context. They do not change what your build ships. A key in client code is still public after you deploy.
Is it okay that my Supabase anon key is in my Cursor app?
Yes, the anon or sb_publishable_ key is meant to be public. It is only safe when Row Level Security is on for every table and your policies limit rows to the right user. See our guide on whether the Supabase anon key is safe to expose.
My OpenAI key has a NEXT_PUBLIC_ prefix. What now?
Treat it as leaked. Revoke it and create a new one in the OpenAI dashboard, set a usage limit, rename the variable without NEXT_PUBLIC_, and call OpenAI only from a server route. Then rebuild and redeploy so the old bundle is replaced.
How do I check the live site instead of my local copy?
Your hosting dashboard can hold different values than your local .env files. Open the live site, look at the JavaScript files it loads in your browser's developer tools, and search them for key prefixes, or run a scan that fetches the live bundles for you.
What does LeakLatch check here?
LeakLatch loads the live URL you give it and its JavaScript bundles, read-only. It looks for known secret key patterns such as OpenAI, Stripe secret, AWS and Supabase service_role or sb_secret_ keys, checks whether Supabase tables answer with your public anon key, and reviews security headers. Secret values are redacted in the report. You must confirm you own the site or have permission to scan it. It is not a substitute for a full security audit.
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