Vite loads .env files itself and injects matching variables into import.meta.env, but only those whose names begin with VITE_. Reading import.meta.env.DATABASE_URL in a component yields undefined no matter what the .env file contains.
This is a security boundary, not an inconvenience. Everything exposed is inlined as a literal into the client bundle and is therefore public. The prefix forces an explicit decision for each variable, which is why renaming a secret to VITE_SECRET to make an error go away is the wrong move.
Inside vite.config.ts the rule does not apply, because config runs in Node, but process.env there contains only the real environment, not the .env files. Use the exported loadEnv(mode, process.cwd(), '') helper to read unprefixed values in config. The prefix itself is configurable through envPrefix, and setting it to an empty string to expose everything is explicitly rejected by Vite.