Files
prowler/ui/app/(auth)/layout.tsx
T
Pablo Fernandez Guerra (PFE) 853610bbbf feat(ui): resolve public SaaS config at container runtime (#11500)
Co-authored-by: Pablo F.G <pablo.fernandez@prowler.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 15:12:18 +02:00

75 lines
2.0 KiB
TypeScript

import "@/styles/globals.css";
import { GoogleTagManager } from "@next/third-parties/google";
import { Metadata, Viewport } from "next";
import { connection } from "next/server";
import { ReactNode, Suspense } from "react";
import { RuntimePublicConfig } from "@/components/runtime-config/runtime-public-config";
import { NavigationProgress, Toaster } from "@/components/ui";
import { fontSans } from "@/config/fonts";
import { siteConfig } from "@/config/site";
import { cn } from "@/lib";
import { readEnv } from "@/lib/runtime-env";
import { Providers } from "../providers";
export const metadata: Metadata = {
title: {
default: siteConfig.name,
template: `%s - ${siteConfig.name}`,
},
description: siteConfig.description,
icons: {
icon: "/favicon.ico",
},
};
export const viewport: Viewport = {
themeColor: [
{ media: "(prefers-color-scheme: light)", color: "white" },
{ media: "(prefers-color-scheme: dark)", color: "black" },
],
};
export default async function AuthLayout({
children,
}: {
children: ReactNode;
}) {
// Force dynamic rendering so the read below resolves from the container env
// at request time rather than being snapshotted at build (independent of the
// <RuntimePublicConfig/> island's own connection() call).
await connection();
// Server-side runtime read. Empty/unset id ⇒ GoogleTagManager is not mounted
const gtmId = readEnv(
"UI_GOOGLE_TAG_MANAGER_ID",
"NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID",
);
return (
<html suppressHydrationWarning lang="en">
<head>
<RuntimePublicConfig />
</head>
<body
suppressHydrationWarning
className={cn(
"bg-background min-h-screen font-sans antialiased",
fontSans.variable,
)}
>
<Providers themeProps={{ attribute: "class", defaultTheme: "dark" }}>
<Suspense>
<NavigationProgress />
</Suspense>
{children}
<Toaster />
{gtmId && <GoogleTagManager gtmId={gtmId} />}
</Providers>
</body>
</html>
);
}