VITE0030Read only exposed env variables in client code
Why it happens
Vite exposes env variables matching envPrefix (VITE_ by default), built-in keys, and import.meta.env.* client defines. Doctor uses resolved Vite evidence when available. Otherwise it reads the owning project's default vite.config file in Vite's lookup order. In Nuxt app code, Doctor skips server-only branches and does not use a serial SSR build as evidence of client exposure. Without client build evidence, Doctor reads unambiguous vite options from nuxt.config and defers when layers, modules, or overrides can change those options. Doctor skips configurations it cannot resolve, including composed configs and known plugins or frameworks that manage env. Test, config, server and SSR entry files are skipped. Doctor also skips TEST, VITEST and the VITEST_* keys set for test-only branches when the owning package declares Vitest, has its own vitest.config file, configures tests through Vite+, or is selected by a static test.projects entry in the workspace root config. Secret-looking names are left to vite/env/no-client-secret-pattern unless the host config proves they are not exposed.
Fix
If the value is public and a prefix is configured, rename it with that prefix in both the .env file and the code. Keep secret values in server-only code.
Example
Use the env prefix Vite exposes
Before
// .env: API_URL=https://api.example.com
const apiUrl = import.meta.env.API_URL
After
// .env: VITE_API_URL=https://api.example.com
const apiUrl = import.meta.env.VITE_API_URL
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm vite-doctor . --framework vite --rules vite/env/no-unprefixed-client-env