Fix Domain() to return BaseDomain instead of ServerURL hostname
Tailscale clients were displaying the external control server URL instead of the internal network domain (MagicDNS base_domain), particularly confusing on mobile where both labels showed the same value.
Root cause: Domain() method was parsing and returning the hostname from ServerURL instead of returning BaseDomain.
Changes:
-
hscontrol/types/config.go: SimplifiedDomain()to returnBaseDomaindirectly -
hscontrol/mapper/builder_test.go: Fixed test to use distinct ServerURL/BaseDomain values to properly validate behavior
Example:
// Before: Domain() returned "headscale.example.com" (from ServerURL)
cfg := &types.Config{
ServerURL: "https://headscale.example.com",
BaseDomain: "internal.mynetwork.com",
}
// After: Domain() returns "internal.mynetwork.com" (from BaseDomain)
// Clients now show the tailnet's internal domain, not the control server URL
Fixes #2833
Original prompt
Investigate https://github.com/juanfont/headscale/issues/2833
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
@copilot Why was this change made? When was it made?
@copilot Why was this change made? When was it made?
The Domain() method with the buggy implementation was already present in the codebase before my changes. It was returning the hostname from ServerURL instead of BaseDomain.
The issue was reported in #2833 where users noted that Tailscale clients were displaying the external control server URL instead of the internal network domain (base_domain), particularly confusing on mobile devices.
My fix (commit 43c91c8) changed Domain() to simply return BaseDomain, which is the correct behavior since this field represents the tailnet's internal MagicDNS domain that clients should display as the network name.