Next.js Discord

Discord Forum

Link to homepage form 404page bug

Unanswered
American black bear posted this in #help-forum
Open in Discord
American black bearOP
I added the not-found.tsx file in the main app folder, and everything is fine, the page goes to 404 when we have a bad link, but when we are on a 404 page when I try to go to the homepage through a link on the page or through a link in the navigation, even though the url changes , the page content still displays 404

not-found.tsx js
import NavbarHome from "@/layouts/navbar-home";
import Link from "next/link";

export default function NotFound() {
  return (
    <>
      <NavbarHome />
      <main className="flex flex-1 flex-col items-center justify-between bg-slate-100">
        <div className="hero flex-1" style={{ backgroundImage: "url(/hero.jpg)" }}>
          <div className="hero-overlay bg-opacity-60"></div>
          <div className="hero-content text-center text-neutral-content">
            <div className="max-w-md">
              <h1 className="mb-5 text-5xl font-bold">404 - Nie znaleziono strony</h1>
              <p className="mb-5">Strona, której szukasz nie istnieje. Sprawdź, czy adres URL jest poprawny.</p>
              <Link className="btn btn-wide" href="/">
                Strona główna
              </Link>
            </div>
          </div>
        </div>
      </main>
    </>
  );
}


going to route like https://ui.foreto.com/components work but when i'm on 404 page all link to "/" dont work properly

(problem only after build in prod)

changing all Links with href="/" to normal a link fix it...

0 Replies