By the end of this lesson you will fix the most common "works on my laptop, broken online" problems: missing environment variables, public prefixes, failed builds, CORS, 404 on refresh and wrong API addresses.
You need: an app you have deployed (or are about to deploy) to a host like Vercel or Netlify · Time: 9 minutes
Your laptop and your host are two different computers. Code goes to the host through Git; some things deliberately don't:
- Your
.envfile holds secrets like API keys. It is in.gitignore, so it is not uploaded. That is correct and safe (Keep secrets secret). - So the host has none of those values until you type them into the host's dashboard.
- The host also builds your app from scratch on a Linux server, which is stricter than Windows or Mac about some things.
Your .env stays on your laptop. The host needs its own copy of every value, then a redeploy. Why?Almost every "works locally, broken online" bug is one of a handful of known causes. Knowing them turns a scary evening into a ten-minute checklist.
- Your
Log in free to read the rest of this lesson
Every lesson is free. A free account unlocks all of them and saves your progress.
Still to come in this lesson:
- Missing environment variables
- Public prefixes: NEXT_PUBLIC_ and VITE_
- When the build fails
- Errors you only see in the live browser
- Your failed-deploy checklist
- Recap