Next.js Discord

Discord Forum

Why the header and footer appears on the error page

Unanswered
Bigheaded ant posted this in #help-forum
Open in Discord
Bigheaded antOP
I have a root layout like this, and have header & footer inside it. But when I try to go to the page that isn't exist, the header and footer rendered on the 404 page. How can I fix this?

export default async function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {

  return (
    <html lang="en">
      <body className={`${inter.className} antialiased`}>
        <AccessPermitted user={user} token={token} />
        <Header user={user}/>

        {children}

        <Footer/>
        <Toaster />
      </body>
    </html>
  );
}

3 Replies

Bigheaded antOP
This is my header.
Bigheaded antOP