From adf2f5921f406d75468bb74da43ff8f802d26cfa Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Fri, 17 Apr 2026 11:42:35 +0700 Subject: [PATCH] fix(app): unblock host index redirect on native by dropping window.location read MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `window` exists on React Native (aliased to `global`) but `window.location` is undefined, so reading `window.location.pathname` threw and killed the redirect effect — leaving the host index route stuck rendering null (blank screen). Use the `pathname` from `usePathname()` directly, restoring the pre-refactor behavior that worked on both web and native. --- packages/app/src/app/h/[serverId]/index.tsx | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/packages/app/src/app/h/[serverId]/index.tsx b/packages/app/src/app/h/[serverId]/index.tsx index 550bbc171..0f6b8c509 100644 --- a/packages/app/src/app/h/[serverId]/index.tsx +++ b/packages/app/src/app/h/[serverId]/index.tsx @@ -14,13 +14,6 @@ import { prepareWorkspaceTab } from "@/utils/workspace-navigation"; const HOST_ROOT_REDIRECT_DELAY_MS = 300; -function getCurrentPathname(fallbackPathname: string): string { - if (typeof window === "undefined") { - return fallbackPathname; - } - return window.location.pathname || fallbackPathname; -} - export default function HostIndexRoute() { return ( @@ -50,13 +43,11 @@ function HostIndexRouteContent() { return; } const rootRoute = buildHostRootRoute(serverId); - const currentPathname = getCurrentPathname(pathname); - if (currentPathname !== rootRoute && currentPathname !== `${rootRoute}/`) { + if (pathname !== rootRoute && pathname !== `${rootRoute}/`) { return; } const timer = setTimeout(() => { - const latestPathname = getCurrentPathname(pathname); - if (latestPathname !== rootRoute && latestPathname !== `${rootRoute}/`) { + if (pathname !== rootRoute && pathname !== `${rootRoute}/`) { return; }