@devries-cameron20 / t3code-1 / commits / 8ea4a88097
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): Tailscale Serve forwards to the address a specific --host binds (#34741)

Julius Marminge committed Nov 11, 2026 at 20:36 UTC 8ea4a8809796abde76093a4edcea2ec39f3a578a
2 files changed +17 -3
apps/server/src/startupAccess.test.ts
+14
@@ -1,9 +1,11 @@
1 import type * as NodeOS from "node:os";
2
3 import { describe, expect, it } from "@effect/vitest";
4 +import * as NetAddress from "effect/net/NetAddress";
5
6 import {
7 acceptsPrivateNetworkConnection,
8 + loopbackUrlHostForAddress,
9 resolveHeadlessConnectionString,
10 } from "./startupAccess.ts";
11
@@ -55,6 +57,18 @@ it("prefers a LAN address over a tailnet one for a private-network pairing URL",
57 ).toBe("http://192.168.1.42:3773");
58 });
59
60 +it("targets the bound interface when the listener binds a specific address", () => {
61 + const hostFor = (ip: string) =>
62 + loopbackUrlHostForAddress(NetAddress.inetAddressFromIpStringUnsafe(ip, 3773));
63 +
64 + expect(hostFor("0.0.0.0")).toBe("127.0.0.1");
65 + expect(hostFor("::")).toBe("127.0.0.1");
66 + expect(hostFor("::1")).toBe("[::1]");
67 + expect(hostFor("127.0.0.1")).toBe("127.0.0.1");
68 + expect(hostFor("127.0.0.2")).toBe("127.0.0.2");
69 + expect(hostFor("100.101.102.103")).toBe("100.101.102.103");
70 +});
71 +
72 describe("acceptsPrivateNetworkConnection", () => {
73 const accepts = (localAddress: string | undefined, remoteAddress: string | undefined) =>
74 acceptsPrivateNetworkConnection({ localAddress, remoteAddress });
apps/server/src/startupAccess.ts
+3 -3
@@ -71,9 +71,9 @@ export const acceptsPrivateNetworkConnection = (socket: {
71 );
72
73 export const loopbackUrlHostForAddress = (address: NetAddress.InetAddress): string =>
74 - address._tag === "InetAddressV6" && NetAddress.isLoopback(address.address)
75 - ? "[::1]"
76 - : "127.0.0.1";
74 + NetAddress.isUnspecified(address.address)
75 + ? "127.0.0.1"
76 + : NetAddress.formatUrlHostString(NetAddress.formatIp(address.address));
77
78 const normalizeHost = (host: string): string =>
79 host.startsWith("[") && host.endsWith("]") ? host.slice(1, -1) : host;