@devries-cameron20 / t3code-1 / commits / 563ba1af19
Fork 0

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

fix(server): port refusals survive T3 Connect's relay (#39763)

Julius Marminge committed Nov 20, 2026 at 07:09 UTC 563ba1af19ddac93c0c7751639a1b42026b4174b
2 files changed +4 -3
apps/server/src/preview/PreviewTunnel.test.ts
+2 -2
@@ -196,7 +196,7 @@ it.effect.each([
196 }),
197 );
198
199 -it.effect("answers a port nothing listens on with 502, marked as about the port", () =>
199 +it.effect("answers a port nothing listens on with 403, marked as about the port", () =>
200 Effect.gen(function* () {
201 const closed = yield* Effect.promise(
202 () =>
@@ -211,7 +211,7 @@ it.effect("answers a port nothing listens on with 502, marked as about the port"
211 const tunnel = yield* serveTunnel();
212 const client = yield* openTunnel(`${tunnel.origin}/api/preview/tunnel?port=${closed}`);
213 const response = yield* refusal(client);
214 - expect(response).toEqual({ status: 502, portRefused: true });
214 + expect(response).toEqual({ status: 403, portRefused: true });
215 }),
216 );
217
apps/server/src/preview/PreviewTunnel.ts
+2 -1
@@ -202,9 +202,10 @@ const handler = Effect.gen(function* () {
202 Effect.succeed(
203 HttpServerResponse.text(error.message, { status: 403, headers: PORT_REFUSED_HEADERS }),
204 ),
205 + // Not 502: Cloudflare, in front of T3 Connect, swaps an origin 502 for its own page.
206 PreviewTunnelConnectError: (error) =>
207 Effect.succeed(
207 - HttpServerResponse.text(error.message, { status: 502, headers: PORT_REFUSED_HEADERS }),
208 + HttpServerResponse.text(error.message, { status: 403, headers: PORT_REFUSED_HEADERS }),
209 ),
210 }),
211 );