fix(cms): resolve double-root-layout conflict between the site and Payload admin

Next.js 16 requires either one shared root layout for every route, or
each top-level route group to be fully self-contained (no ancestor
layout.tsx above it). MITHOME-86 added (payload)/layout.tsx — which
itself renders Payload's own <html>/<body> via <RootLayout> — while
src/app/layout.tsx still existed as a shared ancestor and did the same.
The result was two React trees fighting over <html>/<body>/<head>,
surfacing in the browser as hydration failures and "You are mounting a
new html component" errors on /admin (invisible to curl-based checks
in the MITHOME-86 verification, since they only exercise SSR, not
client hydration — that verification's "confirmed live" claim was
therefore incomplete; caught now with an actual browser).

Fix, per Payload's documented multi-root pattern: move every existing
site route (page.tsx, globals.css, kapcsolat/szolgaltatasok/rolunk/
adatvedelem/felhasznalasi-feltetelek) into a new (frontend) route
group with its own layout.tsx (renamed from src/app/layout.tsx, with
relative imports adjusted one level deeper), as a sibling of (payload).
No shared layout.tsx remains directly under src/app/.

Verified in a real browser (not just curl): /admin/login and the
dashboard now render and hydrate cleanly, and all site routes
(/, /rolunk, /szolgaltatasok, /kapcsolat, /adatvedelem,
/felhasznalasi-feltetelek) are unaffected — same output, just moved.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Do Siki
2026-09-10 03:40:00 +02:00
co-authored by Claude Sonnet 5
parent 2a4f33172b
commit a661739844
9 changed files with 0 additions and 0 deletions
+112
View File
@@ -0,0 +1,112 @@
import type { Metadata, Viewport } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import Header from "../components/Header";
import Footer from "../components/Footer";
import { ThemeProvider } from "../components/ThemeProvider";
import { siteConfig } from "../config/site";
import { common } from "../content";
const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
});
const geistMono = Geist_Mono({
variable: "--font-geist-mono",
subsets: ["latin"],
});
export const metadata: Metadata = {
// WHY metadataBase: without it Next resolves relative OG/twitter image URLs
// against localhost, producing broken social previews in production.
metadataBase: new URL(siteConfig.general.url),
title: `${siteConfig.general.name} | ${siteConfig.general.description}`,
description: siteConfig.general.description,
authors: [{ name: siteConfig.general.name }],
keywords: ["web hosting", "email szolgáltatás", "DNS adminisztráció", "IT szolgáltatás", "mozdIT"],
openGraph: {
title: siteConfig.general.name,
description: siteConfig.general.description,
url: siteConfig.general.url,
siteName: siteConfig.general.name,
images: [
{
url: siteConfig.general.ogImage,
width: 1200,
height: 630,
alt: siteConfig.general.name,
},
],
locale: siteConfig.general.locale,
type: "website",
},
twitter: {
card: "summary_large_image",
title: siteConfig.general.name,
description: siteConfig.general.description,
images: [siteConfig.general.ogImage],
},
robots: {
index: true,
follow: true,
googleBot: {
index: true,
follow: true,
"max-video-preview": -1,
"max-image-preview": "large",
"max-snippet": -1,
},
},
};
// Keep Safari's browser chrome neutral; only the in-page staging strip is amber.
export const viewport: Viewport = {
themeColor: '#ffffff',
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
const isStaging = process.env.NEXT_PUBLIC_DEPLOY_ENV === 'staging';
return (
<html lang="hu" suppressHydrationWarning>
<head>
<script
dangerouslySetInnerHTML={{
__html: `
(function() {
const savedTheme = localStorage.getItem('theme');
if (savedTheme === 'dark') {
document.documentElement.setAttribute('data-theme', 'dark');
} else if (savedTheme === 'light') {
document.documentElement.setAttribute('data-theme', 'light');
}
})();
`,
}}
/>
</head>
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased min-h-screen flex flex-col`}
style={{ background: 'var(--color-background)', color: 'var(--color-foreground)' }}
>
<ThemeProvider>
{isStaging && (
<div className="bg-amber-400 px-4 py-2 text-center text-xs font-extrabold tracking-[0.18em] text-amber-950 sm:text-sm">
{common.staging.banner}
</div>
)}
<Header />
<main className="flex-1">
{children}
</main>
<Footer />
</ThemeProvider>
</body>
</html>
);
}