News for hackers. Stuff that matters.
Re:.localhost Domains by vlod on Thursday April 10, 2025 @11:02AM (#43644531)
Anyone care to shed why myapp.localhost:3000 (for the webapp I'm developing) is something that's useful for me rather than localhost:3000 ?

EDIT: on linux and don't use launchd, so I'd still the port number

Re:.localhost Domains by jeroenhd on Thursday April 10, 2025 @11:05AM (#43644573)
Using real domain names lets you experience the web as it is in production. Localhost has a bunch of exceptions (i.e. HTTP URLs are treated as secure, CORS acts funny, etc.). Using domain names disables special handling of localhost URLs that'll help you spot problems before they hit production.
Re:.localhost Domains by vlod on Thursday April 10, 2025 @11:08AM (#43644611)
Thanks. This is the reason I wanted rather then convenience of not typing a port number (which I'd use a bookmark for, so I really don't care)
Re:.localhost Domains by ghoshbishakh on Thursday April 10, 2025 @02:13PM (#43646618)
Trick: edit yuor /etc/hosts file and add a domain name.

Self sign a certificate and add it to your trusted certificate list.

Or - use https://pinggy.io

Re:.localhost Domains by cyral on Thursday April 10, 2025 @11:47AM (#43645096)
Note the use of the Caddy webserver (you could also use nginx or whatever), which proxies to the port, so it's just myapp.localhost. I like this because it mirrors our production site. We can have subdomain.myapp.localhost and subdomain.myapp.com so links and everything work properly in both environments (assuming you have an env variable for the base domain)
Re:.localhost Domains by oulipo on Thursday April 10, 2025 @12:01PM (#43645259)
Could there be a way to setup the Caddy server dynamically using eg direnv so that it's only launched when I'm in my dev folder?
Re:.localhost Domains by mrweasel on Thursday April 10, 2025 @11:08AM (#43644606)
Maybe you have a stack of applications that needs to communicate. Seeing db.localhost is a little easier to read that db:3360, but especially if you have multiple web applications. It's easier to read sso.localhost, api.localhost, and www.localhost.

They also show having the webserver to the TLS, that might be helpful.

Re:.localhost Domains by csciutto on Thursday April 10, 2025 @11:07AM (#43644601)
The comparison is `myapp.localhost` vs `localhost:3000`. This is especially useful when you have web servers permanently running on your computer on ports, not just for momentaneous local development.
Re:.localhost Domains by gwd on Thursday April 10, 2025 @11:06AM (#43644588)
It's `myapp.localhost` (without the port number). It's more useful because it's easier to allocate and remember a unique name than a unique port number.
Re:.localhost Domains by tgpc on Thursday April 10, 2025 @11:07AM (#43644599)
maybe you're running a reverse proxy? it can direct you differently depending on how you refer to it