cleaning hard 2

This commit is contained in:
alma 2025-05-03 12:23:39 +02:00
parent 04ef5d59c0
commit 080984ec71

View File

@ -1,7 +1,12 @@
import type { Metadata } from "next";
import { Inter } from "next/font/google"; import { Inter } from "next/font/google";
import "./globals.css"; import "./globals.css";
import { headers } from "next/headers";
import { getServerSession } from "next-auth/next";
import { authOptions } from "@/app/api/auth/[...nextauth]/route";
import { LayoutWrapper } from "@/components/layout/layout-wrapper";
import { warmupRedisCache } from '@/lib/redis';
import dynamic from 'next/dynamic'; import dynamic from 'next/dynamic';
import { Suspense } from 'react';
// Dynamically import heavy components with proper typing // Dynamically import heavy components with proper typing
const Providers = dynamic(() => import('@/components/providers'), { const Providers = dynamic(() => import('@/components/providers'), {
@ -11,21 +16,48 @@ const Providers = dynamic(() => import('@/components/providers'), {
const inter = Inter({ subsets: ["latin"] }); const inter = Inter({ subsets: ["latin"] });
// Warm up Redis connection during app initialization
warmupRedisCache().catch(console.error);
export const metadata = { export const metadata = {
title: "Neah Front", title: "Neah Front",
description: "Neah Front Application", description: "Neah Front Application",
}; };
export default function RootLayout({ export default async function RootLayout({
children, children,
}: { }: {
children: React.ReactNode; children: React.ReactNode;
}) { }) {
// Try to get the session, but handle potential errors gracefully
let session = null;
let sessionError = false;
try {
session = await getServerSession(authOptions);
} catch (error) {
console.error("Error getting server session:", error);
sessionError = true;
}
const headersList = await headers();
const pathname = headersList.get("x-pathname") || "";
const isSignInPage = pathname === "/signin";
// If we're on the signin page and there was a session error,
// don't pass the session to avoid refresh attempts
const safeSession = isSignInPage && sessionError ? null : session;
return ( return (
<html lang="en" suppressHydrationWarning> <html lang="fr" suppressHydrationWarning>
<body className={inter.className}> <body className={inter.className}>
<Providers> <Providers session={safeSession}>
{children} <LayoutWrapper
isSignInPage={isSignInPage}
isAuthenticated={!!session && !sessionError}
>
{children}
</LayoutWrapper>
</Providers> </Providers>
</body> </body>
</html> </html>