Middleware + notFound is not working
See original GitHub issueVerify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System: Platform: win32 Arch: x64 Version: Windows 10 Pro Binaries: Node: 14.19.1 npm: N/A Yarn: N/A pnpm: N/A Relevant packages: next: 12.2.0 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
When using middleware and navigate to a page using next/link
that return in it’s getStaticProps
a { notFound:true }
the middleware returns the page itself instead of 404.
Expected Behavior
When the page returns { notFound: true }
the middleware should return 404 page.
Link to reproduction
https://github.com/Louai99k/next-not-found-bug
To Reproduce
Just install the repo above and run it on your machine. You’ll notice in the main page 2 links one normal anchor tag and a next/link
. if the middleware exist the link comp from next won’t work while the a tag will be working but after removing the middleware both of the links will work just fine.
Not: the api end point returns 404 response and that’s my condition in the project to return 404 page.
Issue Analytics
- State:
- Created a year ago
- Reactions:17
- Comments:10 (1 by maintainers)
Top GitHub Comments
Closing as this does appear to be working as expected in the latest version of Next.js
Had the same issue with
getServerSideProps
. Seems to be fixed in the most recent release12.3.1
.