Returning notFound from getStaticProps causes an error during next export
#24422
Labels
Milestone
Comments
|
Experiencing the exact same issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What version of Next.js are you using?
10.1.3, 10.1.4-canary.16
What version of Node.js are you using?
14.15.3
What browser are you using?
Firefox 89.0b3
What operating system are you using?
Ubuntu 18.04.5 LTS
How are you deploying your application?
next export
Describe the Bug
If a page returns
{ notFound: true }fromgetStaticProps, then runningnext build && next exportwill result in an error like the following:It seems like
next exportexpects an html file to be present, but there isn't one.Expected Behavior
No error message,
next exportfinishes successfully, and visiting/blog/postin production results in a 404 just like when I usenext build && next startlocallyTo Reproduce
You can find a minimal reproduction with instructions in the readme here: https://github.com/fracture91/next-notfound-ssg-bug There's also a canary branch showing the issue still exists in 10.1.4-canary.16
For a little context, my use case is I want to be able to see unpublished blog posts in dev mode, but production builds should exclude them and result in a 404. Here is my "real" code where I hit the problem, plus a hacky workaround.
Another potential workaround is to avoid using
next exportin my Vercel deploy, since my example repo seems to work fine withnext buildalone.These comments look like the same problem: #19578 (comment) #20355
The text was updated successfully, but these errors were encountered: