`envPrefix: ''` forbids starting the dev server
Author: y-nkCreated Jul 17, 2025Updated Sep 17, 2026
Labelspending triage
Describe the bug
In my vite config, i want to set envPrefix: '' because i'm building a backend server locally and i know what i'm doing.
Reproduction
Steps to reproduce
- create a vite project (with a mindset that it'll be for a backend server / ssr)
- add
envPrefix: '' - run
vite
→ my log output:
11:00:46 | api | error when starting dev server:
11:00:46 | api | Error: envPrefix option contains value '', which could lead unexpected exposure of sensitive
information.
11:00:46 | api | at resolveEnvPrefix
Notes
i think a warning is fine, but blocking people from loading env var when they accept their fate isn't ; especially when leveraging vite for building a BE/ssr app
Workaround
Sadly i don't think there's a workaround except for prefixing all my env vars with _ (which sucks). I can't use define since what i wish to accomplish is that import.meta.env gets populated (which seems not to be the case when using define: {})
System Info
System:
OS: macOS 15.5
CPU: (8) arm64 Apple MX XXXXXX
Memory: 109.39 MB / XXXX.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.16.0
pnpm: 10.10.0
Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Source: vitejs/vite