You're right, Chan — sharp catch. Vite loads .env.local in every mode, dev and build alike, so the exercise's "build shows the .env value" step doesn't actually hold: the production build keeps the .env.local override and you end up shipping localhost. Renaming it to .env.development.local is exactly the fix — that file only loads under npm run dev, so npm run build falls back to .env the 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. 🙂
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.localand expects the production build to fall back to.env. But in Vite,.env.localoverrides 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.localto.env.development.localThis forces the localhost URL to only load during
npm run dev. Then when you runnpm run build, it'll properly switch over to the production URL in your.env.Save yourselves the headache and change the filename!