Fix login redirect issues with subpath handling in WUD - #1138
Open
balaji-g42 wants to merge 2 commits into
Open
Conversation
Fixes several related bugs that surface when running WUD behind a reverse proxy with a stripped subpath (WUD_SERVER_BASEPATH), causing session-expiry redirects to land on /login instead of /<basepath>/login: - getPublicUrl() never appended the configured basepath, so OIDC redirect_uri and post-login redirects dropped the subpath entirely. - url() concatenated basepath and path without ensuring a separating slash, breaking API calls whenever basepath had no trailing slash (e.g. "/wud" + "auth/strategies" -> "/wudauth/strategies"). - registerServiceWorker.ts registered the service worker against the build-time process.env.BASE_URL instead of the runtime-injected basepath. - The service worker precached index.html, so Workbox's default directoryIndex mapping served a stale, non-basepath-injected shell for navigation requests instead of the live per-request server response, permanently freezing the wrong basepath for the SW's lifetime. index.html is now excluded from the precache manifest.
Replace console.log/error fallbacks with eventBus notifications or silent handling to satisfy no-console lint rule in production builds.
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.
This pull request introduces improvements to how public URLs and paths are constructed and handled across both the backend and frontend, ensuring correct behavior when a base path is configured. It adds comprehensive tests for these scenarios and updates service worker registration and PWA configuration to better handle dynamic base paths.
Backend URL Construction and Testing:
getPublicUrlfunction inapp/configuration/index.tsto correctly append the server base path to the public URL or request origin, and updated its logic to handle cases where bothWUD_PUBLIC_URLandWUD_SERVER_BASEPATHare set.app/configuration/index.test.tsto verifygetPublicUrlbehavior with different combinations of environment variables and request origins.Frontend URL Construction and Testing:
urlfunction inui/src/services/base.tsto ensure paths are joined correctly, always inserting a slash between the base path and the requested path, and preventing double slashes.ui/tests/services/base.spec.tsto verify the correct joining of base paths and paths in different scenarios, including with and without trailing slashes.Service Worker and PWA Configuration:
ui/src/registerServiceWorker.tsto use the updatedurlfunction for determining the service worker script path, ensuring compatibility with dynamic base paths.ui/vue.config.jsto excludeindex.htmlfrom the service worker precache, as it is generated dynamically per request with base path injection.