Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.
This repository was archived by the owner on Jul 6, 2026. It is now read-only.

Discobot not resolving *.localhost subdomains for service preview #5

Description

@wskish

Problem

When running discobot macOS binary and trying to access a service preview with a subdomain of localhost (e.g., http://my-service.localhost:52865), Safari and Discobot/Tauri (WKWebView) fail to load the page. Chrome and curl work fine.

Root Cause

Chrome and curl resolve *.localhost to 127.0.0.1 — Chrome via its built-in resolver (per https://datatracker.ietf.org/doc/html/rfc6761#section-6.3), and curl via getaddrinfo() which macOS resolves at the OS level.

Safari and Tauri use Apple's CFNetwork / NSURLSession stack, which has its own DNS resolution path that does not special-case *.localhost subdomains. Instead, it sends a real DNS query, which fails because no upstream DNS server has a record for the subdomain.

This is a longstanding omission in Apple's networking stack. RFC 6761 recommends that localhost and its subdomains always resolve to loopback, but CFNetwork does not implement this.

Workaround

Install dnsmasq

brew install dnsmasq

Resolve all *.localhost to 127.0.0.1

echo "address=/localhost/127.0.0.1" >> $(brew --prefix)/etc/dnsmasq.conf

Start as a persistent service

sudo brew services start dnsmasq

Route .localhost DNS queries to the local resolver

sudo mkdir -p /etc/resolver
echo "nameserver 127.0.0.1" | sudo tee /etc/resolver/localhost

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions