Getting 500 errors instead of 404 errors for unknown urls in directories with dynamic urls

Hello,

Our site uses dynamic pages i.e. blog/[post], resources/[resource] etc, as well as at the root directory ( /[slug] ).

https://6212f294701b550007a7d8d1--aomail.netlify.app
https://6212f294701b550007a7d8d1--aomail.netlify.app/direct-mail
https://6212f294701b550007a7d8d1--aomail.netlify.app/blog/bali-recipe-book-fulfilment

When entering a URL within these directories that does not match a valid page (e.g. blog/asdfadf), the site displays the 500 error page.
The expectation is that it should show a 404 page.

https://6212f294701b550007a7d8d1--aomail.netlify.app/invalidurl
https://6212f294701b550007a7d8d1--aomail.netlify.app/blog/invalidurl

When entering an invalid page in an unknown directory, the site correctly displays the 404 page.

https://6212f294701b550007a7d8d1--aomail.netlify.app/invaliddirectory/invalidurl

Our site uses getStaticPaths for all dynamic routes

We do have a redirects file but removing it entirely makes no difference to the result here. I tried adding manual 404 redirects for the dynamic directories but it broke things at the root directory and I received warnings of conflicts for the other directories.

Is this expected behaviour or is there anything I can do to make invalid URLs at the dynamic directory display a 404 instead of 500 error?

Thanks

Hey @ao-olia,

This is most likely a bug with the plugin which could be related to: [Bug]: Fallback false is ignored · Issue #1179 · netlify/next-runtime · GitHub

Thank you @hrishikesh I have subscribed to that thread

1 Like