Skip to content
Every tutorial here is 100% free — and always will be
LSLovableStudent

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

  1. 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.

  2. Use the Code editor's search to look for suspicious patterns yourself: sk_, key=, Bearer , apiKey, .env.

  3. Check any front-end fetch calls that pass a key directly in a header or query string — that key is exposed.

  4. 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

Website made, maintained and hosted by PromptSites.com

PromptSites logo