fix(pwa): let auth proxies redirect before service worker serves cached HTML#534
Merged
fix(pwa): let auth proxies redirect before service worker serves cached HTML#534
Conversation
…ed HTML Replace navigateFallback with a NetworkFirst navigation route so that reverse-proxy authentication (e.g. Authelia) can issue 302 redirects to the login page before the service worker short-circuits navigation with a cached index.html. Only HTTP 200 responses are stored in the navigation cache, ensuring auth redirects are never cached and always reach the browser.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Replaced
navigateFallback: 'index.html'+navigateFallbackDenylistwith a dedicatedNetworkFirstruntime caching rule scoped to navigation requests (request.mode === 'navigate').Why
When the app is deployed behind an authentication reverse-proxy (e.g. Authelia), the proxy responds to unauthenticated requests with a
302redirect to the login page. The previous Workbox configuration usednavigateFallback, which intercepts every navigation request in the service worker and immediately returns the cachedindex.html— before the request reaches the network. This meant the auth redirect was silently swallowed and the login page was never shown.How it works now
302, the browser receives and follows it → Authelia login page is shown.200responses are stored innavigation-cache(cacheableResponse: { statuses: [200] }), so auth redirects are never cached.200response for offline support.The
/webdavand/sabnzbddenylist entries are no longer needed since there is no navigation fallback to deny.Test plan
bun run build)