page not found 404 in route groups
Unanswered
Egyptian Mau posted this in #help-forum
Egyptian MauOP
Hello,
I am planning to use
and I saw there's a bug already ---- https://github.com/vercel/next.js/issues/59180
any help on this how to handle this issue?
I am planning to use
Payload CMS which required to have Route Group in the Nextjs as /src/apps/(payload) & /src/apps/(frontend) -- but if I add not-found.tsx in the /src/apps/(frontend)/not-found.tsx then it's not executing when I am opening the URL --- localhost:3000/missing then the not-found from the /apps/(frontend) is executing, as there's no other layout or not-found in /src/apps/and I saw there's a bug already ---- https://github.com/vercel/next.js/issues/59180
any help on this how to handle this issue?
1 Reply
@Egyptian Mau Hello,
I am planning to use `Payload CMS` which required to have Route Group in the Nextjs as `/src/apps/(payload)` & `/src/apps/(frontend)` -- but if I add `not-found.tsx` in the `/src/apps/(frontend)/not-found.tsx` then it's not executing when I am opening the URL --- `localhost:3000/missing` then the `not-found` from the `/apps/(frontend)` is executing, as there's no other layout or not-found in `/src/apps/`
and I saw there's a bug already ---- https://github.com/vercel/next.js/issues/59180
any help on this how to handle this issue?
Poodle
Yeah, this is a known Next.js bug with multiple root layouts and not-found. The issue is still open.
Workaround until it's fixed:
1. Create a catch-all route in your frontend group:
2. Keep your
This forces unmatched routes in your frontend group to hit your custom not-found page instead of the root 404.
Not ideal, but it works until Vercel fixes the core issue.
Workaround until it's fixed:
1. Create a catch-all route in your frontend group:
/src/app/(frontend)/[...not-found]/page.tsximport { notFound } from 'next/navigation';
export default function NotFoundCatchAll() {
notFound();
}2. Keep your
not-found.tsx in /src/app/(frontend)/not-found.tsx — the catch-all will trigger it.This forces unmatched routes in your frontend group to hit your custom not-found page instead of the root 404.
Not ideal, but it works until Vercel fixes the core issue.