Most active commenters

    ←back to thread

    .localhost Domains

    (inclouds.space)
    301 points todsacerdoti | 12 comments | | HN request time: 1.279s | source | bottom
    1. vlod ◴[] No.43644531[source]
    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

    replies(8): >>43644573 #>>43644584 #>>43644588 #>>43644599 #>>43644601 #>>43644606 #>>43644652 #>>43645096 #
    2. jeroenhd ◴[] No.43644573[source]
    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.
    replies(2): >>43644611 #>>43646618 #
    3. ◴[] No.43644584[source]
    4. gwd ◴[] No.43644588[source]
    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.
    5. tgpc ◴[] No.43644599[source]
    maybe you're running a reverse proxy? it can direct you differently depending on how you refer to it
    6. csciutto ◴[] No.43644601[source]
    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.
    7. mrweasel ◴[] No.43644606[source]
    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.

    8. vlod ◴[] No.43644611[source]
    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)
    9. ◴[] No.43644652[source]
    10. cyral ◴[] No.43645096[source]
    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)
    replies(1): >>43645259 #
    11. oulipo ◴[] No.43645259[source]
    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?
    12. ghoshbishakh ◴[] No.43646618[source]
    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