Adding middleware breaks 404 functionality on dynamic page for client side #43953
Closed
1 task done
Labels
bug
Issue was opened via the bug report template.
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
Middleware / Edge (API routes, runtime), Routing (next/router, next/navigation, next/link)
Link to the code that reproduces this issue
https://github.com/TheMatrixan/next-bug-middleware-dynamic-page
To Reproduce
/dynamic/123
- this url should exists and should return dynamic component content -DynamicPage
/dynamic/789
- this url doesn't exist in dynamic path routes and when you go to that page, it will displayDynamicPage
instead of custom 404 page. BUT, when you refresh the page, it will display correct custom 404 page.middleware.ts
file and when you will click on link/dynamic/789
, it will display correct 404 page.Describe the Bug
By adding just empty function as a middleware, when we navigate to page that doesn't exist in static paths, next will show empty dynamic page content on client side instead of 404. When we delete middleware, Next will correctly show 404 page for page that doesn't exist.
Expected Behavior
link
/dynamic/789
should display custom 404 page on client side while navigating between pages.Which browser are you using? (if relevant)
Chrome 108.0.5359.95 (64-bits)
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: