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 check Supabase RLS?Ask Lovable to list every table and its row-level security status and policies in plain language — Lovable Cloud users don't have Supabase dashboard access, so this has to go through chat.
- AnswerHow do I prevent spam registrations?Verify email addresses on sign-up, add a CAPTCHA to the registration form, rate-limit sign-up attempts per IP, and check the token server-side before creating an account.
- AnswerHow do I stop bots?Add a CAPTCHA (e.g. Cloudflare Turnstile) to public forms, validate inputs server-side, and rate-limit submissions — client-side-only checks like a hidden field are easy for real bots to bypass.
- 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.