The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 19:45 UTC
fix(scripts): --share --built --host localhost points the tailnet URL at the backend (#35542)
Julius Marminge committed
Nov 12, 2026 at 11:18 UTC
0c3a9982b1b6d90741ba1d5b1893ccdb1068b2d2
2 files changed
+19
-2
scripts/dev-runner.test.ts
+9
@@ -574,6 +574,15 @@ it.layer(NodeServices.layer)("dev-runner", (it) => {
574
}),
575
);
576
577
+ // Node resolves localhost to ::1 first, so a 127.0.0.1 target can miss the backend.
578
+ it.effect("--built --host localhost keeps the backend's localhost name", () =>
579
+ Effect.gen(function* () {
580
+ const { env, tailscaleCalls } = yield* shareSpawned({ built: true, host: "localhost" });
581
+ const serve = tailscaleCalls.find((args) => args.includes("--bg"));
582
+ assert.equal(serve?.at(-1), `http://localhost:${env?.T3CODE_PORT}`);
583
+ }),
584
+ );
585
+
586
it.effect("without --built keeps Vite behind the tailnet URL", () =>
587
Effect.gen(function* () {
588
const { env, vpArgs, tailscaleCalls } = yield* shareSpawned({});
scripts/dev-runner.ts
+10
-2
@@ -59,6 +59,13 @@ export function isProxiableBindHost(host: string): boolean {
59
);
60
}
61
62
+function sharedBackendTargetHost(host: string | undefined): string {
63
+ const normalized = host?.trim() ?? "";
64
+ if (normalized === "::1" || normalized === "[::1]") return "[::1]";
65
+ if (normalized === "localhost") return "localhost";
66
+ return "127.0.0.1";
67
+}
68
+
69
export const DEFAULT_T3_HOME = Effect.map(Effect.service(Path.Path), (path) =>
70
path.join(NodeOS.homedir(), ".t3"),
71
);
@@ -788,12 +795,13 @@ export const runDevRunnerWithInput = Effect.fn("dev-runner.runDevRunnerWithInput
795
shareDevServer({
796
webPort: sharedWebPort,
797
// The backend binds 127.0.0.1 unless --host changes it. A wildcard
791
- // still answers there; `--host ::1` binds only the IPv6 loopback.
798
+ // still answers there; `--host ::1` binds only the IPv6 loopback, and
799
+ // `localhost` binds whichever loopback Node resolves first.
800
...(input.built
801
? {
802
localTarget: {
803
port: Number(env.T3CODE_PORT),
796
- host: ["::1", "[::1]"].includes(input.host?.trim() ?? "") ? "[::1]" : "127.0.0.1",
804
+ host: sharedBackendTargetHost(input.host),
805
},
806
}
807
: {}),