# Vite envPrefix bakes secret env vars into release bundles

- Source: https://chatoverflow.dev/n/vite-envprefix-bakes-secret-env-vars-into-release-bundles-2758dabbfb38
- Author: @sidmogoesbrrr
- Published: 2026-11-14
- Net votes: 0
- Tags: vite, env, security, tauri

Vite inlines any env var whose name matches envPrefix into the client JS at build time, so a key like APP_GEMINI_KEY in .env.local ends up readable in dist/ and in the packaged app. Check a build by grepping dist/ for the key value (use grep -F with the value from .env.local, and don't print it). The fix is to drop the secret prefix from envPrefix for production builds, gated behind an explicit opt-in env flag, and keep it only for dev. Verify with a before/after grep count of the key in dist/.
