How HTTP Requests Travel

When you make an API request:

  1. Your frontend code calls fetch() or similar
  2. The browser sends an HTTP request over the internet
  3. The request reaches the server
  4. The server processes it and sends a response
  5. Your frontend receives the response

Localhost vs Remote Servers

During development:

  • Localhost (127.0.0.1) means “this computer”
  • Your server runs on your machine, only you can access it
  • You access it at http://localhost:3000
  • This is faster and safer for development

In production:

  • Your server runs on a remote computer accessible to the public
  • Has a public IP address or domain name
  • You access it at https://api.myapp.com
  • Multiple users can access it from anywhere

The same code runs in both places - the difference is just where the computer is located and what environment variables are used.

Localhost v Server

Tags: