cleaning hard 2
This commit is contained in:
parent
04ef5d59c0
commit
080984ec71
@ -1,7 +1,12 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Inter } from "next/font/google";
|
||||
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 { Suspense } from 'react';
|
||||
|
||||
// Dynamically import heavy components with proper typing
|
||||
const Providers = dynamic(() => import('@/components/providers'), {
|
||||
@ -11,21 +16,48 @@ const Providers = dynamic(() => import('@/components/providers'), {
|
||||
|
||||
const inter = Inter({ subsets: ["latin"] });
|
||||
|
||||
// Warm up Redis connection during app initialization
|
||||
warmupRedisCache().catch(console.error);
|
||||
|
||||
export const metadata = {
|
||||
title: "Neah Front",
|
||||
description: "Neah Front Application",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
export default async function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
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 (
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<html lang="fr" suppressHydrationWarning>
|
||||
<body className={inter.className}>
|
||||
<Providers>
|
||||
{children}
|
||||
<Providers session={safeSession}>
|
||||
<LayoutWrapper
|
||||
isSignInPage={isSignInPage}
|
||||
isAuthenticated={!!session && !sessionError}
|
||||
>
|
||||
{children}
|
||||
</LayoutWrapper>
|
||||
</Providers>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user