How HTTP Requests Travel
When you make an API request:
- Your frontend code calls
fetch()or similar - The browser sends an HTTP request over the internet
- The request reaches the server
- The server processes it and sends a response
- 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.
