From 8b0e2052cf8aa88c308ea5a6093f38f5a55a85d6 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Tue, 12 May 2026 16:10:29 +0200 Subject: [PATCH] fix: honor NEXT_PUBLIC_BASE_PATH in admin sidebar nav links #271 --- app/admin/layout.tsx | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/app/admin/layout.tsx b/app/admin/layout.tsx index 693f0289..a9b759fc 100644 --- a/app/admin/layout.tsx +++ b/app/admin/layout.tsx @@ -31,7 +31,7 @@ import { useThemeStore } from '@/stores/theme-store'; import { getActiveAccountSlotHeaders } from '@/lib/auth/active-account-slot'; import { useUpdateStore, selectHasUpdate } from '@/stores/update-store'; -import { apiFetch } from '@/lib/browser-navigation'; +import { apiFetch, getPathPrefix } from '@/lib/browser-navigation'; // Single-page tab navigation: clicks update a Zustand store. The URL stays // at /admin so React doesn't fire a route transition on every tab switch - @@ -177,6 +177,12 @@ export default function AdminLayout({ children }: { children: React.ReactNode }) return <>{children}>; } + // /admin lives outside the [locale] tree, so links back to the webmail + // apps are bare tags (hard navigation). Next.js only auto-applies + // basePath to /router APIs — for these we prepend it manually so + // NEXT_PUBLIC_BASE_PATH=/webmail deployments don't redirect to "/". + const prefix = getPathPrefix(); + const navContent = ( <> @@ -274,28 +280,28 @@ export default function AdminLayout({ children }: { children: React.ReactNode }) )} @@ -306,7 +312,7 @@ export default function AdminLayout({ children }: { children: React.ReactNode }) @@ -411,7 +417,7 @@ export default function AdminLayout({ children }: { children: React.ReactNode }) aria-label="Main navigation" > @@ -419,7 +425,7 @@ export default function AdminLayout({ children }: { children: React.ReactNode }) Mail @@ -427,7 +433,7 @@ export default function AdminLayout({ children }: { children: React.ReactNode }) Calendar @@ -435,7 +441,7 @@ export default function AdminLayout({ children }: { children: React.ReactNode }) Contacts @@ -454,7 +460,7 @@ export default function AdminLayout({ children }: { children: React.ReactNode }) Admin