Next.js 14 - Unable to serve 404 using Optional Catch-All Segments

Next.js version: 14.2.3
Next.js Runtime version: 5.6.0

I have a folder at app/[[...path]] that is using optional catch-all segments and my goal is to serve a 404 when a page outside of generateStaticParams is accessed.

Per the Next.js documentation, I am setting the dynamicParams option to false in order to achieve this: File Conventions: Route Segment Config | Next.js

When running the site locally, I can visit a page such as /this-does-not-exist and see the 404 template. After deploying to Netlify, the same page shows an error: " Application error: a server-side exception has occurred (see the server logs for more information)."

From what I can tell, it looks like the error thrown by the notFound() function is uncaught instead of triggering the 404 page. Should the Next.js Runtime be able to support this feature?

What’s the site URL?

Homepage: https://www.vividfront.com/
404 Page: https://www.vividfront.com/this-page-does-not-exist

I’m unable to reproduce this: hrishikesh-k/f-123713 (github.com). Site: 404: This page could not be found. (f-123713.netlify.app)

Ok, thank you for setting up a repo to test. I will need to create a minimum reproducible example since it seems like my initial idea was wrong.

1 Like

This issue can be closed. There was an uncaught 404 error in the generateMetadata() method that was short-circuiting the built-in Next.js error handler.