Files
Scriberr/web
Paul Irish 6e707f363c fix(auth): prevent infinite fetch recursion and multiple wrapper layers
This fixes an issue where the frontend would spam the auth endpoints repeatedly when logged out or when a session expired.

1. Infinite Recursion on 401: The window.fetch wrapper would catch a 401, call tryRefresh(), which then called fetch() again, triggering the wrapper recursively if the refresh also failed. We now use the original fetch for refresh attempts and exclude auth endpoints from auto-refresh logic.
2. Multiple Wrapper Layers: Since useAuth is a hook used by many components, multiple instances were independently wrapping window.fetch. We now store the original fetch globally and ensure wrapping only happens once.
2026-02-28 10:58:17 -08:00
..