-
Notifications
You must be signed in to change notification settings - Fork 414
Description
Auth.tsx redirects are happening in component render cycle.
In combination with the serviceworker intercepting requests,
can lead to situations where the component is rerendering and making repeated requests fast.
We should move the redirection to a guarded useEffect.
Reproduce:
- Have service worker activated
- Delete the
docs_sessionid
cookie after already authenticated and reload. - Should see multiple cancelled requests
(for us in opendesk it ends in a loop for 25 or so requests per second)
Old issue description (before the issues cause was clearer)
The redirect to the `authenticate|callback|logout` endpoints should not be intercepted by the service worker. They need to be top-level redirects (window.location=...) for the browser to set the `docs_sessionid` cookie correctly.
They are not like regular api endpoints which just return cachable data, these endpoints can redirect and the browser must follow the redirect to properly set the session cookie.
Intercepting them at the service-worker for offline use, leads to the service-worker pre-checking if data is available with an XHR/fetch (browser will not follow) and causing the actual top-level redirect to be cancelled. Causes redirect loops.
This is probably causd by the catch‑all API route matching /authenticate/:
docs/src/frontend/apps/impress/src/features/service-worker/service-worker-api.ts
Lines 107 to 124 in 62e122b
registerRoute( | |
({ url }) => isApiUrl(url.href), | |
new NetworkFirst({ | |
cacheName: getCacheNameVersion('api'), | |
plugins: [ | |
new CacheableResponsePlugin({ statuses: [0, 200] }), | |
new ExpirationPlugin({ | |
maxAgeSeconds: 24 * 60 * 60 * DAYS_EXP, | |
}), | |
new ApiPlugin({ | |
type: 'synch', | |
syncManager, | |
}), | |
new OfflinePlugin(), | |
], | |
}), | |
'GET', | |
); |
Metadata
Metadata
Assignees
Labels
Type
Projects
Status