From 523443f1d7d46a5d08451e31d0d74f7434e5a341 Mon Sep 17 00:00:00 2001 From: xvilo Date: Sat, 5 Sep 2026 22:06:49 +0900 Subject: [PATCH] fix(app): stop mounting authed-only widgets on public visitor routes SystemNoticeHost, BackgroundTasksWidget, and save-to-collection were gated only on login/register/password routes, so anonymous visitors to /shared/:token and /public/journey/:token still mounted them and hit system-notices/active with no session, logging a 401 on every visit. --- client/src/App.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/client/src/App.tsx b/client/src/App.tsx index 1eeeaefe8..1eaeedbcb 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -402,13 +402,18 @@ export default function App() { || location.pathname.startsWith('/register') || location.pathname.startsWith('/forgot-password') || location.pathname.startsWith('/reset-password') + // Anonymous visitor routes: no session, so authenticated-only widgets (system + // notices, background tasks, save-to-collection) have nothing to do here and + // would otherwise fire a doomed authenticated request on mount. + const isPublicVisitorPage = isSharedPage || location.pathname.startsWith('/public/journey/') + const hideAuthedWidgets = isAuthPage || isPublicVisitorPage return ( - {!isAuthPage && } + {!hideAuthedWidgets && } - {!isAuthPage && } - {!isAuthPage && (isPhone ? : )} + {!hideAuthedWidgets && } + {!hideAuthedWidgets && (isPhone ? : )} {/* One boundary for all route chunks, above so it stays mounted across navigations. react-router runs location updates inside a transition,