From 60a1cc670c328fa32a6183300d925ccab4eb9ca1 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Thu, 9 Jul 2026 13:30:44 +0200 Subject: [PATCH] fix: apply per-domain favicon override in root metadata #585 --- app/(main)/layout.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/(main)/layout.tsx b/app/(main)/layout.tsx index 04a86963..a8af157f 100644 --- a/app/(main)/layout.tsx +++ b/app/(main)/layout.tsx @@ -5,6 +5,11 @@ import { headers } from "next/headers"; import { getLocale, getTranslations } from "next-intl/server"; import { ServiceWorkerRegistration } from "@/components/service-worker-registration"; import { configManager } from "@/lib/admin/config-manager"; +import { + matchDomainBranding, + parseDomainBranding, + pickRequestHost, +} from "@/lib/admin/domain-branding"; import { withBasePath } from "@/lib/browser-navigation"; import { locales } from "@/i18n/routing"; import "../globals.css"; @@ -39,7 +44,19 @@ export const viewport: Viewport = { export async function generateMetadata(): Promise { await configManager.ensureLoaded(); - const faviconUrl = configManager.get("faviconUrl", "/branding/Bulwark_Favicon.svg"); + // The favicon must honor per-domain branding, exactly like + // /api/config, app/manifest.ts, and /api/pwa-icon already do. Resolve the + // request host and prefer its override; fall back to the global + // admin/env/default value when the host has no favicon override (#585). + const host = pickRequestHost(await headers()); + const domainOverride = matchDomainBranding( + host, + parseDomainBranding(configManager.get("domainBranding", [])), + ).faviconUrl; + const faviconUrl = + domainOverride && domainOverride.length > 0 + ? domainOverride + : configManager.get("faviconUrl", "/branding/Bulwark_Favicon.svg"); // Localize the description to match the UI language; a hardcoded // English description is another signal that makes Chrome offer to // "translate this page". Resolve the locale from the request path, since this