How do secrets leak through frontend environment variables?

A value compiled into browser code is readable by visitors. Separate a public API key from a service credential. Having “env” in a variable name does not make it private; inspect the generated JavaScript.

How to check it

  1. Find which variables browser code uses.
  2. Keep service-role and management credentials on the server.
  3. Scan build output for sensitive variable names and value patterns.

Concrete example

Example: a Supabase publishable key can be used by a client while RLS restricts data access. Putting a service-role credential in that bundle breaks the intended security boundary.

Avoid a false conclusion

Deleting an exposed secret from a file is insufficient. Revoke or rotate it, inspect access logs and account for historical copies.

Reference

Official reference

VCT Editorial

All answers