Learning on Web Dev Open is free for all.

Backend Engineering > A server from nothingRunning it locally without lying to yourself
Phase 05A server from nothing240 of 434

Running it locally without lying to yourself

Ports, environment variables, hot reload and the gap between your machine and anywhere else.

Concept10 minAI pair

Read configuration from the environment from the first commit, not the first deploy. A port that is process.env.PORT ?? 3000 costs nothing today and saves an afternoon later, because every platform you will deploy to assigns the port and expects you to listen on it.

Hot reload is a development-only convenience and it lies in one specific way: it restarts the process, which quietly resets any state you were holding in memory. If your service works locally only because a Map survived between requests, you have written something that cannot run as two instances, and you will find that out on the day traffic justifies a second one.

You should now be able to

  • Configure a service through the environment rather than constants
  • Name three ways local differs from production
Ask the community

Loading…