dynamic nested route matches where it should 404
See original GitHub issueBug report
Describe the bug
Give the pages structure
/pages
/[post]
/[comment].js
/user
/home.js
When you visit the url /user/non-existing it will render /[post]/[comment].js instead of 404. It’s clear that the developer intends for the /user prefix to be its own subsection, so when visiting routes in that subsection it is unexpected to match anything form the /[post] folder.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Example at https://codesandbox.io/s/goofy-moore-mmi49
- Go to
/user/non-existing - Observe
Expected behavior
It should 404
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
dynamic nested route matches where it should 404 #10550
Go to /user/non-existing; Observe. Expected behavior. It should 404. The text was updated successfully, but these errors were ...
Read more >Handle 404 pages for nested routes in react-router
One of the major challenge with nested routes is to handle Not found pages. Now as the routes are nested , there is...
Read more >Dynamic Routes Details - Next.js
Here is some essential information you should know about dynamic routes. ... then any paths not returned by getStaticPaths will result in a...
Read more >How to render page 404 on dynamic routes : React
The url is matched and it will show the LocationPage component. What you can do it is show an empty location component when...
Read more >Routing - Remix
Nested Routes - The general idea of routes mapping to segments of the URL allowing the full URL to map to a hierarchy...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This is expected behavior imo. You have a dynamic top level route and it matches that.
Eg if the behavior you described would be implemented zeit.co would break on user account routes / dashboard routes
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.