Hasty Briefsbeta

Bilingual

Don't use localhost:3000, use your own custom domain

17 hours ago
  • #Web Development
  • #Nginx Configuration
  • #Localhost Setup
  • The author ran a demo that appeared to use a custom domain (www.internaltool.com) instead of localhost, leading colleagues to mistakenly think they purchased a domain.
  • Setting up custom domains locally is an old-school practice that has declined with the rise of bundled servers (like in Node.js), but it remains useful for managing multiple long-term projects that need to communicate.
  • The method involves editing the system's hosts file (/etc/hosts) to map domain names (e.g., myproject.com) to 127.0.0.1, directing them to the local machine instead of the internet.
  • Nginx is used as a reverse proxy to forward traffic from port 80 to the specific ports where applications are running (e.g., port 3000 or 3001), enabling clean, professional URLs like dev.myproject.com.
  • For WSL2 users, networking differs; the IP address from the Linux instance (obtained via 'wsl hostname -I') must be used in the Windows hosts file instead of 127.0.0.1.
  • The approach offers practical benefits for separating development environments, enhances professionalism in demos, and avoids the mental fatigue of managing port numbers.