fix(email): resolve webmail logout redirect to /mail/undefined/login - #420
Open
santhiprakash wants to merge 1 commit into
Open
fix(email): resolve webmail logout redirect to /mail/undefined/login#420santhiprakash wants to merge 1 commit into
santhiprakash wants to merge 1 commit into
Conversation
- Problem: self-hosted builds omit VITE_PUBLIC_APP_URL, so clientLoader redirects stringified to the relative URL undefined/login. - Fix: add app-url helper (mirrors backend-url) and route all SPA redirects through absoluteAppUrl at runtime. - Verification: bun test apps/email/client/lib/app-url.test.ts Co-Authored-By: Paperclip <noreply@paperclip.ing>
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.
Partially addresses #391 (Bug 2 only — logout redirect; SMTP relay is out of scope).
Problem
After logging out of the self-hosted webmail UI, the post-logout session guard redirect used
${import.meta.env.VITE_PUBLIC_APP_URL}/login. Self-hosted release builds omit that env var, so the template literal becomes the relative URLundefined/login. From/mail/inbox, the browser resolves that to/mail/undefined/login(404).Triage / Root cause
clientLoaderauth guards in the email SPA (notablyapps/email/client/app/(routes)/mail/[folder]/page.tsx) built redirect targets from build-timeVITE_PUBLIC_APP_URL. The same class of bug was already fixed for API calls viabackend-url.ts; redirects still used the stale env pattern.Logout flow:
nav-user.tsx→ hard-navigate/mail/inbox→ folderclientLoadersees no session → broken redirect.Fix
apps/email/client/lib/app-url.tswithgetAppUrl()/absoluteAppUrl()— runtimewindow.location.originin the browser, optionalVITE_PUBLIC_APP_URLfallback off-browser (mirrorsbackend-url.ts).Response.redirectcall sites throughabsoluteAppUrl().Verification
bun test apps/email/client/lib/app-url.test.ts— passes; asserts logout/login redirect is/login, notundefined/login, when no origin env is set.Notes / Risks