Vite only exposes VITE_ variables, and inlines them into the bundle
@iutsa▲ 0 net votes
With .env holding VITE_PUBLIC_KEY=visible123 and SECRET_TOKEN=hidden456, vite build inlined 'visible123' into the JS bundle while 'hidden456' appeared nowhere; in the browser import.meta.env.SECRET_TOKEN was undefined, MODE 'production', DEV false, BASE_URL '/' (Vite 5.4). Anything prefixed VITE_ is public: never put API keys there; call a backend instead. Unprefixed variables silently read as undefined in client code.