fix: let browser handle navigation requests to support auth proxies#2069
Open
pakerfeldt wants to merge 1 commit intoFlowFuse:mainfrom
Open
fix: let browser handle navigation requests to support auth proxies#2069pakerfeldt wants to merge 1 commit intoFlowFuse:mainfrom
pakerfeldt wants to merge 1 commit intoFlowFuse:mainfrom
Conversation
When the dashboard sits behind an authentication proxy (Cloudflare Access, OAuth2 Proxy, Authelia, etc.), the service worker must not intercept navigation requests. Otherwise it serves a cached index.html, preventing the browser from following HTTP redirects to the login page when the auth session expires. Remove the NavigationRoute + createHandlerBoundToURL registration and disable precacheAndRoute's directoryIndex and cleanURLs options so it cannot implicitly serve index.html for navigation requests. Static assets (JS, CSS, fonts, images) are still served from the precache via exact URL match, so page loads remain fast.
Author
|
With issue #2068 and this PR, I hope we can have a conversation on how to resolve the problem. This PR is a suggested solution that has been proving to work for me, but maybe people with more experience of service workers would come up with a better approach. |
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.
Description
When the dashboard is deployed behind an authentication proxy (Cloudflare Access, OAuth2 Proxy, Authelia, etc.), the service worker intercepts all navigation requests and serves a cached
index.html. This prevents the browser from following the proxy's HTTP redirect to the login page when the auth session expires, resulting in "There was an error loading the Dashboard."Remove the
NavigationRouteregistration so the service worker never handles navigation requests. The browser performs normal network navigation and can follow auth redirects naturally.To prevent
precacheAndRoutefrom implicitly servingindex.htmlfor navigation requests (via itsdirectoryIndexandcleanURLsdefaults), both options are explicitly disabled.Static asset requests (JS, CSS, fonts, images) are unaffected, they are not navigation requests and continue to be served from the precache via exact URL match.
Testing
Tested behind Cloudflare Access (Zero Trust) with Google IdP:
Related Issue(s)
Fixes #2068
Checklist
Unsure how we would write tests for the service worker.
flowforge.yml?FlowFuse/helmto update ConfigMap TemplateFlowFuse/CloudProjectto update values for Staging/ProductionLabels
area:migrationlabel