Skip to content

fix(email): resolve webmail logout redirect to /mail/undefined/login - #420

Open
santhiprakash wants to merge 1 commit into
oblien:mainfrom
santhiprakash:fix/webmail-logout-redirect
Open

fix(email): resolve webmail logout redirect to /mail/undefined/login#420
santhiprakash wants to merge 1 commit into
oblien:mainfrom
santhiprakash:fix/webmail-logout-redirect

Conversation

@santhiprakash

Copy link
Copy Markdown
Contributor

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 URL undefined/login. From /mail/inbox, the browser resolves that to /mail/undefined/login (404).

Triage / Root cause

clientLoader auth guards in the email SPA (notably apps/email/client/app/(routes)/mail/[folder]/page.tsx) built redirect targets from build-time VITE_PUBLIC_APP_URL. The same class of bug was already fixed for API calls via backend-url.ts; redirects still used the stale env pattern.

Logout flow: nav-user.tsx → hard-navigate /mail/inbox → folder clientLoader sees no session → broken redirect.

Fix

  • Add apps/email/client/lib/app-url.ts with getAppUrl() / absoluteAppUrl() — runtime window.location.origin in the browser, optional VITE_PUBLIC_APP_URL fallback off-browser (mirrors backend-url.ts).
  • Route all SPA Response.redirect call sites through absoluteAppUrl().

Verification

Notes / Risks

  • Scoped to Bug 2 only per CONTRIBUTING one-change-per-PR.
  • Also fixes the same latent bug in settings/mailto/create loaders that used the same env pattern.

- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant