How do I check for exposed environment variables?
Last checked 31 Aug 2026
Short answer
Ask Lovable to search your codebase for hard-coded API keys and secrets in front-end files, then move anything sensitive into a server function or edge function.
Why this matters
Anything shipped in your front-end bundle — including Vite import.meta.env.VITE_* variables — is downloadable by anyone who opens your published site's dev tools. Only secrets that must run server-side (Stripe secret keys, third-party API keys, email provider keys) are actually at risk; the Supabase URL and anon key are designed to be public.
How to check
Open Chat and ask Lovable directly:
Search the whole codebase for any API keys, secrets or tokens that are hard-coded in front-end components, and tell me if any should be moved server-side.
Use the Code editor's search to look for suspicious patterns yourself:
sk_,key=,Bearer,apiKey,.env.Check any front-end fetch calls that pass a key directly in a header or query string — that key is exposed.
Run Lovable's built-in Security overview scan (see /questions/how-do-i-check-a-lovable-project-for-security-vulnerabilities), which flags exposed secrets automatically.
What to do if you find one
- Move the call into a Supabase edge function (Lovable Cloud) or server function, and store the real key as a secret there — never in a front-end file.
- Rotate the exposed key with the provider immediately; assume it's compromised once it has shipped in a public bundle.
- Ask Lovable to update the front-end code to call your new server endpoint instead of the third-party API directly.
What usually goes wrong
- Builders paste an API key into a prompt "to test quickly" and it ends up in a component. Always specify server-side storage up front.
VITE_(or similarly public) prefixed env vars are bundled into client code by design — never put a secret behind one.- Rotating a key without updating the server function's secret leaves the app broken; do both together.
See also /questions/is-my-supabase-anon-key-safe-to-expose for the one common "leak" that's actually fine.
Sources
Was this answer helpful?
Related questions
- AnswerHow do I protect API keys?Never put API keys in front-end code — store them as secrets used only inside server functions (Edge Functions), where the browser never sees them.
- AnswerAre Lovable websites secure?Lovable includes built-in security scanning and API-key protection, but real security also depends on you setting up row-level security and role checks correctly — it isn't automatic just because you used Lovable.
- AnswerWhere should secrets be stored?In your project's server-side secrets store, used only inside Edge Functions — never in front-end code, client-side environment variables, or committed to your Git repository.
- AnswerHow do I run a security audit on Lovable?Open your project's Security view in Lovable to see automated scan results, then ask Lovable in chat to review RLS policies, role storage, and any exposed secrets in detail.