From d53ccc924603ef83a8fadae0375df1924bba93b5 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 8 May 2026 22:26:15 -0700 Subject: [PATCH] fix hosted channel bootstrap --- apps/web/src/hostedPairing.test.ts | 12 ++++++++++++ apps/web/src/hostedPairing.ts | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/apps/web/src/hostedPairing.test.ts b/apps/web/src/hostedPairing.test.ts index ea592780db..983094c1e5 100644 --- a/apps/web/src/hostedPairing.test.ts +++ b/apps/web/src/hostedPairing.test.ts @@ -79,4 +79,16 @@ describe("hostedPairing", () => { vi.stubEnv("VITE_HTTP_URL", "https://backend.example.com"); expect(isHostedStaticApp(new URL("https://preview.t3.codes/"))).toBe(false); }); + + it("detects hosted channel aliases as static apps", () => { + vi.stubEnv("VITE_HOSTED_APP_URL", "https://app.t3.codes"); + vi.stubEnv("VITE_HOSTED_APP_CHANNEL", "nightly"); + vi.stubEnv("VITE_HTTP_URL", ""); + vi.stubEnv("VITE_WS_URL", ""); + + expect(isHostedStaticApp(new URL("https://nightly.app.t3.codes/"))).toBe(true); + + vi.stubEnv("VITE_HTTP_URL", "https://backend.example.com"); + expect(isHostedStaticApp(new URL("https://nightly.app.t3.codes/"))).toBe(false); + }); }); diff --git a/apps/web/src/hostedPairing.ts b/apps/web/src/hostedPairing.ts index 8ebe7ac257..cc547323f8 100644 --- a/apps/web/src/hostedPairing.ts +++ b/apps/web/src/hostedPairing.ts @@ -18,6 +18,11 @@ function configuredBackendUrl(): string { return import.meta.env.VITE_HTTP_URL?.trim() || import.meta.env.VITE_WS_URL?.trim() || ""; } +function configuredHostedAppChannel(): HostedAppChannel | null { + const channel = import.meta.env.VITE_HOSTED_APP_CHANNEL?.trim().toLowerCase(); + return channel === "latest" || channel === "nightly" ? channel : null; +} + function originFromUrl(value: string): string | null { try { return new URL(value).origin; @@ -31,6 +36,10 @@ export function isHostedStaticApp(url: URL = new URL(window.location.href)): boo return false; } + if (configuredHostedAppChannel()) { + return true; + } + const hostedOrigin = originFromUrl(configuredHostedAppUrl()); return hostedOrigin !== null && url.origin === hostedOrigin; }