ISR page deployed to Vercel does not respect `notFound` if its been previously built
See original GitHub issueBug report
Describe the bug
A ISR page, deployed to Vercel, that’s been rendered and cached once will never show a 404 again even if notFound: true
is returned from getStaticProps
.
To Reproduce
- Create a new app using
npx create-next-app
- Create the page
pages/[slug].js
looking something like this:
export default function PostTemplate({ post: { title }}) {
return (
<h1>{title}</h1>
)
}
export async function getStaticPaths() {
return {
paths: [],
fallback: "blocking",
}
}
export async function getStaticProps({ params: { slug } }) {
const res = await fetch(`https://yourapi.com/posts/${slug}`)
const post = await res.json()
return {
props: {
post
},
notFound: !post, // For this example, let's pretend my API returns a nullish value when a post is missing
revalidate: 1
}
}
- Deploy to Vercel
- Publish a post with the slug
my-post
- Visit
yourdeployment.vercel.app/my-post
and the post is successfully rendered - Unpublish the post
- Reload the page and get a stale version (expected)
- Reload again and you will still get the post even though
getStaticProps
returnednotFound: true
during the previous revalidation.
Expected behavior
Im expecting the 404 page to be rendered as the previous revalidation returned notFound: true
Screenshots
N/A
System information
- OS: macOS
- Chrome 87
- Version of Next.js: 10.0.3
- Version of Node.js: 12.x
- Deployment: Vercel
Additional context
If i run the same app locally (npm start
) and try this, the 404 will get displayed as expected which makes me suspect it might be related to the Vercel platform.
Let me know if you need me to provide an example app or if anything is unclear.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Incremental Static Regeneration – Vercel Docs
Incremental Static Regeneration (ISR) allows you to create or update content without redeploying your site. ISR has three main benefits for developers: ...
Read more >Next.js custom _error page only works locally - Stack Overflow
js 9.4.4, the custom _error page works on Vercel, but it doesn't appear you can deploy a Next.js app below version 10 on...
Read more >Remix vs Next.js
Another thing that makes deploying to Vercel great is that their CDN supports it. You might wonder why the Remix port isn't as...
Read more >Next.js: The Good, Bad and Ugly - An Idiosyncratic Blog
If you've never heard about Next.js, it's a framework built on top of React ... This is useful when the page does not...
Read more >Vercel | Miguel Minoldo
Prevent security issues – users should not be able to canonically access. // the pages/sites folder and its respective contents. if (url.pathname.
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
I believe the previously generated
page.html
is left in.next/server/pages/page.html
and not cleared when the page is rebuilt withnotFound: true
. I’m experiencing the following behavior locally:next build && next export
of a page withnotFound: true
fails due to.next/server/pages/page.html
not existingnotFound: true
, now we are able tonext build && next export
notFound: true
, now we are still able tonext build && next export
.next/
, now we get a failure again when attempting tonext build && next export
The issue I’m seeing is that
next export
is attempting to look for the built html file for anotFound: true
page, and then either failing due to it not existing or incorrectly using the old version if it exists.Hi, this should now be fixed! I’m going to close this issue, if you are still experiencing problems with this please reply with additional information and we can investigate further.