From 03f4470db6f633f5f830ca190a52bbb888e0e3ce Mon Sep 17 00:00:00 2001 From: Oliver Kieselbach Date: Tue, 20 Oct 2026 10:31:16 +0200 Subject: [PATCH] The sign-in return no longer prefetches the target route (D-366) Measured in production with 300 ms latency, router.prefetch loaded only the route tree while auth/me was in flight, and the replace still fetched the route payload after auth/me: no gain on the critical path, one to three extra requests per sign-in return. Co-Authored-By: Claude Opus 5.5 --- .../components/landing/AuthGate.tsx | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/Web/autopilot-monitor-web/components/landing/AuthGate.tsx b/src/Web/autopilot-monitor-web/components/landing/AuthGate.tsx index efdc3870..9416ec9f 100644 --- a/src/Web/autopilot-monitor-web/components/landing/AuthGate.tsx +++ b/src/Web/autopilot-monitor-web/components/landing/AuthGate.tsx @@ -2,7 +2,7 @@ import { useAuth } from "../../contexts/AuthContext"; import { useRouter } from "next/navigation"; -import { useEffect, useRef } from "react"; +import { useEffect } from "react"; import type { Route } from "next"; import { landingTarget } from "../../lib/landingTarget"; import { consumePostLoginReturnUrl, peekPostLoginReturnUrl } from "../../lib/postLoginReturn"; @@ -10,7 +10,6 @@ import { portalHandoverUrl, shouldCrossOriginToPortal } from "../../lib/hostRout import { consumePendingRehome, getSelectedAuthApp, legacyConfigured, switchAuthApp, tryBeginRehome } from "../../lib/authApp"; import { activeAuthApp } from "../../lib/msalConfig"; import { trackEvent } from "../../lib/appInsights"; -import { trustedRoute } from "../../lib/routes"; import { AUTH_PENDING_CLASS, hasAuthHint, holdsAuthOverlay } from "../../lib/authHint"; /** @@ -23,16 +22,6 @@ export function AuthGate() { const { isAuthenticated, isLoading, user, isActivationPending } = useAuth(); const router = useRouter(); - // Load the target's route payload while auth/me is still in flight, so the replace below commits - // without a further round trip. Same-origin only: on the public host the target lives on portal. - const targetPrefetched = useRef(false); - useEffect(() => { - if (!isAuthenticated || targetPrefetched.current || shouldCrossOriginToPortal()) return; - targetPrefetched.current = true; - const returnUrl = peekPostLoginReturnUrl(); - router.prefetch(returnUrl ? trustedRoute(returnUrl) : "/dashboard"); - }, [isAuthenticated, router]); - useEffect(() => { if (isAuthenticated && !isLoading && user) { // Dual app-reg window: the sign-in that just completed ran on the other app than the