Skip to content

Commit 519c3e1

Browse files
committed
fix: only enter hosted-static mode for window-origin targets on bootstrap failure
The catch block in beforeLoad was treating every error from ensurePrimaryEnvironmentReady() and resolveInitialServerAuthGateState() as a signal to enter hosted-static mode. This meant desktop and self-hosted deployments with an explicitly configured backend would silently degrade to an empty app shell on transient failures, instead of showing the error page with a 'Try again' button. Now the catch checks the primary environment target source. Only when the target is 'window-origin' (the fallback used by the hosted app at app.t3.codes with no backend at the origin) does it enter hosted-static mode. For 'desktop-managed' or 'configured' targets, the error propagates to TanStack Router's errorComponent as before.
1 parent 814c206 commit 519c3e1

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

apps/web/src/environments/primary/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ export {
3232
__resetServerAuthBootstrapForTests,
3333
} from "./auth";
3434

35-
export { resolvePrimaryEnvironmentHttpUrl, isLoopbackHostname } from "./target";
35+
export {
36+
resolvePrimaryEnvironmentHttpUrl,
37+
isLoopbackHostname,
38+
readPrimaryEnvironmentTarget,
39+
} from "./target";

apps/web/src/routes/__root.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import { configureClientTracing } from "../observability/clientTracing";
5555
import {
5656
ensurePrimaryEnvironmentReady,
5757
getPrimaryKnownEnvironment,
58+
readPrimaryEnvironmentTarget,
5859
resolveInitialServerAuthGateState,
5960
updatePrimaryEnvironmentDescriptor,
6061
} from "../environments/primary";
@@ -81,7 +82,8 @@ export const Route = createRootRouteWithContext<{
8182
authGateState,
8283
};
8384
} catch (error) {
84-
if (location.pathname === "/pair") {
85+
const primaryTarget = readPrimaryEnvironmentTarget();
86+
if (location.pathname === "/pair" || primaryTarget?.source !== "window-origin") {
8587
throw error;
8688
}
8789

0 commit comments

Comments
 (0)