Story Details

  • .localhost Domains

    Posted: 2025-04-10 14:19:06

    The post advocates for using custom local domains, like project.localhost or api.localhost, instead of just localhost for development. This approach offers several benefits, including easier configuration of virtual hosts, clearer separation of different projects, and more realistic testing environments, especially for cookie handling and CORS issues. The author guides readers through setting up these custom domains using either the system's hosts file or a local DNS resolver like dnsmasq, and explains how to generate wildcard SSL certificates with mkcert for secure HTTPS connections on these local domains. This setup mirrors production environments more closely, making development smoother and more efficient.

    Summary of Comments ( 76 )
    https://news.ycombinator.com/item?id=43644043

    Hacker News users discuss the practicality and security implications of using .localhost domains. Some highlight potential DNS rebinding attacks if not configured correctly, while others point out that using localhost or 127.0.0.1 directly is simpler and avoids such risks. A few commenters appreciate the convenience .localhost offers for testing multiple services on different ports, mimicking production environments more closely. Others suggest alternative solutions like *.test or utilizing a local DNS server. The overall sentiment leans towards caution, with many questioning the added value of .localhost given its potential downsides. Several users find the concept interesting but express concerns about broader adoption and potential confusion it might introduce.