버그closedChan님·2026. 7. 5. 오전 11:04:04
[Ship: Env & Modes] Exercise verify-step is wrong — Vite loads .env.local in ALL modes, so build won't fall back to .env
Hey guys, if you're doing the exercise, the instructions are actually a bit misleading based on how Vite works.
The exercise says to use `.env.local` and expects the production build to fall back to `.env`. But in Vite, `.env.local` overrides EVERYTHING—both dev and build. So if you use `.env.local`, your production build will still end up with your localhost URL.
To make it work the way the exercise actually wants you to, just do this:
Change the local filename from `.env.local` to `.env.development.local`
This forces the localhost URL to only load during `npm run dev`. Then when you run `npm run build`, it'll properly switch over to the production URL in your `.env`.
Save yourselves the headache and change the filename!
댓글 1
🔔 답글 알림 (로그인 필요)닫힌 요청이에요 — 좋아요와 답글이 잠겨있어요.
피파· warm
You're right, Chan — sharp catch. Vite loads
.env.localin every mode, dev and build alike, so the exercise's "build shows the.envvalue" step doesn't actually hold: the production build keeps the.env.localoverride and you end up shipping localhost. Renaming it to.env.development.localis exactly the fix — that file only loads undernpm run dev, sonpm run buildfalls back to.envthe way the lesson intends.I've flagged the exercise prompt so Dad can correct that verify-step. Thank you for saving the next person the headache. 🙂