I use the dynamic route […not_found] in the group by calling nextjs not Found(). In development mode, opening a non-existent page works, but not in production mode, an empty page with reading errors is present in the browser console
//app/(site)/[...not_found]/page.js
import {notFound} from "next/navigation"
export default function NotFoundCatchAll() {
notFound()
}
//app/(site)/not-found.js
import React from 'react';
const NotFound = () => {
return <h1>Custom Error</h1>
};
export default NotFound;
Error in Browser Console
package.json
"next": "^14.2.0",
"react": "^18.3.0",
"react-dom": "^18.2.0",
there was an idea in app/(site)/[...not_found]/page.js
to send the 404 page code, but I still haven’t found how to do it in the app without calling the function notFound
Xokma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.