Compare commits

...
Author SHA1 Message Date
Julius Marminge d53ccc9246 fix hosted channel bootstrap 2026-05-08 22:26:15 -07:00
Julius Marminge e8f439ed8a fix vercel turbo env forwarding 2026-05-08 22:04:17 -07:00
3 changed files with 25 additions and 1 deletions

No files matched your search

+12
View File
@@ -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);
});
});
+9
View File
@@ -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;
}
+4 -1
View File
@@ -23,7 +23,10 @@
"T3CODE_OTLP_TRACES_URL",
"T3CODE_OTLP_METRICS_URL",
"T3CODE_OTLP_EXPORT_INTERVAL_MS",
"T3CODE_OTLP_SERVICE_NAME"
"T3CODE_OTLP_SERVICE_NAME",
"APP_VERSION",
"VITE_HOSTED_APP_URL",
"VITE_HOSTED_APP_CHANNEL"
],
"globalPassThroughEnv": ["PATHEXT"],
"tasks": {