LeakLatch

For Lovable, Bolt, Cursor and Supabase apps

Are VITE_ and NEXT_PUBLIC_ variables public?

Direct answer

Yes. Vite (used by Lovable and Bolt) copies every VITE_ variable into the JavaScript it builds, and Next.js does the same with NEXT_PUBLIC_ variables. Anyone who opens your site can read those values in their browser. Publishable keys such as the Supabase anon key or Stripe pk_ key are fine there. Secret keys such as OpenAI, Stripe sk_, or Supabase service_role must stay on a server.

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.

Owner checks

How to check your own project

Use these on a project you own or have permission to test. They only read your own files and settings; nothing here changes your app.

  1. Step 1

    Know what the prefix means

    Vite only exposes variables that start with VITE_ to your app, and it writes their values straight into the JavaScript it builds. Next.js does the same with NEXT_PUBLIC_ variables at build time. The prefix is not a naming style; it is the switch that makes a value public to every visitor.

  2. Step 2

    List every public variable your app uses

    Open your .env file and your hosting settings and write down each VITE_ or NEXT_PUBLIC_ name. For each one, ask: would I be fine posting this value on my homepage? If the answer is no, it does not belong behind that prefix.

  3. Step 3

    Sort keys into publishable and secret

    Publishable keys are built to be public: the Supabase anon or sb_publishable_ key, the Stripe pk_ key, a Firebase web config, a Google Maps browser key with referrer limits. Secret keys are not: Stripe sk_live_ and sk_test_, OpenAI sk-, Anthropic sk-ant-, the Supabase service_role JWT or sb_secret_ key, Resend re_, AWS secret keys, GitHub tokens.

  4. Step 4

    Search the built bundle, not just your source

    Build the app and search the output folder for secret prefixes with the commands below. A key can reach the bundle through an env var, a hard-coded string an AI assistant added, or a config file that got imported by mistake.

  5. Step 5

    Check the live site after each deploy

    Your hosting dashboard can hold different values than your local .env. Open the deployed site, view its JavaScript files, and check what actually shipped, or run a read-only scan of the live URL.

# Run in your own project folder after a production build.
# Vite (Lovable, Bolt):        npm run build  -> output in dist/
# Next.js (Cursor, v0):        npm run build  -> output in .next/static/

# Search the built client files for common secret prefixes:
grep -rEo "sk_live_[A-Za-z0-9]{8}|sk_test_[A-Za-z0-9]{8}|sk-(proj-)?[A-Za-z0-9_-]{12}|sk-ant-[A-Za-z0-9_-]{8}|sb_secret_[A-Za-z0-9_-]{6}|re_[A-Za-z0-9]{10}|AKIA[0-9A-Z]{16}|gh[pousr]_[A-Za-z0-9]{12}" dist .next/static 2>/dev/null

# List which env names your client code reads:
grep -rEoh "(import\.meta\.env|process\.env)\.(VITE|NEXT_PUBLIC)_[A-Z0-9_]+" src app 2>/dev/null | sort -u

Copy-paste fix

Move secrets 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, then rotate any key that already shipped.

You are helping me remove secret keys from the client side of my own app. Keep existing features working.

1. List every environment variable with a VITE_ or NEXT_PUBLIC_ prefix and every hard-coded API key in the frontend code.
2. Mark each one publishable (Supabase anon/sb_publishable_, Stripe pk_, Firebase web config) or secret (Stripe sk_, OpenAI sk-, Anthropic sk-ant-, Supabase service_role/sb_secret_, Resend re_, AWS, GitHub tokens).
3. For every secret: move the code that uses it into a server function (Supabase Edge Function, Vercel/Netlify function, or Next.js route handler), read the key from a server-only env var with no public prefix, and call that function from the frontend instead.
4. Remove the secret from the frontend, the .env public variables, and any committed files. Tell me which keys I must rotate in each provider's dashboard because they already shipped.
5. Rebuild and confirm none of the secret prefixes appear in the build output.

FAQ

Straight answers about public env variables

Is it safe to put my OpenAI API key in a VITE_ variable?

No. Anything in a VITE_ variable ends up in the JavaScript every visitor downloads, so anyone can copy the key and run up your bill. Call OpenAI from a server function (a Supabase Edge Function, a Vercel or Netlify function, or a Next.js route handler) and keep the key in a server-only variable without the VITE_ or NEXT_PUBLIC_ prefix.

My Supabase anon key is in VITE_SUPABASE_ANON_KEY. Is that a leak?

No. The anon or publishable key is designed to be public. It is safe only when Row Level Security is on for every exposed table and the policies are correct. The service_role or sb_secret_ key is different: it bypasses RLS and must never have a VITE_ or NEXT_PUBLIC_ prefix.

Does .gitignore on my .env file keep the key private?

It keeps the file out of your repository, which is good, but it does nothing for the built app. When you build, Vite and Next.js copy the values of public-prefixed variables into the JavaScript files you deploy. Those files are public no matter what your .gitignore says.

I already shipped a secret key. Is deleting the variable enough?

No. Assume it was copied. Revoke or rotate the key in the provider's dashboard first, then move the call to a server function, redeploy, and check the provider's usage logs for activity you do not recognise. Old builds and caches can keep the old value around.

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 such as Stripe secret keys, OpenAI and Anthropic keys, Supabase service_role JWTs and sb_secret_ keys, AWS access key IDs, Resend and GitHub tokens. Secret values are redacted in the report. Publishable keys are shown as informational. 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