From 247ef6313cbc141c2aabc89ec1540ce3d69e021c Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+frooodle@users.noreply.github.com> Date: Wed, 10 Jun 2026 12:13:20 +0100 Subject: [PATCH] fix: stop login loop caused by unguarded folder-sync 401 The deployed app looped /login -> / -> /login forever: Login sees a valid Supabase session and navigates to /, the global FolderProvider pulls GET /api/v1/storage/folders, the backend rejects it with 401, and the global error handler hard-redirects back to /login?from=/bpp. fileSyncService's /api/v1/storage/files pull already opts out via suppressErrorToast + skipAuthRedirect, so its 401 fails silently; folderSyncService.list() passed neither flag, so its 401 fell through to the redirect. Add the same flags - FolderContext.pullFromServer already handles 4xx locally (flips serverReachable, suppresses the banner). Note: the underlying 401 on /api/v1/storage/* with a valid session is a backend/deployment issue (storage endpoints rejecting the Supabase token); this change makes the frontend resilient so it degrades to "folder sync unavailable" instead of an auth loop. Co-Authored-By: Claude Opus 4.8 --- .../editor/src/core/services/folderSyncService.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontend/editor/src/core/services/folderSyncService.ts b/frontend/editor/src/core/services/folderSyncService.ts index 90af78270..7d863f0c2 100644 --- a/frontend/editor/src/core/services/folderSyncService.ts +++ b/frontend/editor/src/core/services/folderSyncService.ts @@ -62,8 +62,21 @@ function toFolderRecord(dto: ServerFolder): FolderRecord { export const folderSyncService = { async list(): Promise { + // Background sync fired automatically by the global FolderProvider on + // every (non-auth-route) load. If the backend rejects the request with a + // 401 - e.g. the storage API doesn't accept this deployment's session + // token - the error must NOT reach the global 401 handler: that handler + // hard-redirects to /login, the login page sees a valid session and + // bounces back to /, FolderProvider pulls again, and the app loops + // login->/->login forever. FolderContext.pullFromServer already handles + // 4xx locally (flips serverReachable, no banner), so fail silently here - + // mirroring fileSyncService's /api/v1/storage/files pull. const response = await apiClient.get( "/api/v1/storage/folders", + { + suppressErrorToast: true, + skipAuthRedirect: true, + }, ); return (response.data ?? []).map(toFolderRecord); },