Skip to content

Commit 0888742

Browse files
committed
fix: always revalidate
1 parent 14c8a35 commit 0888742

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/runtime/src/templates/server.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ const getNetlifyNextServer = (NextServer: NextServerType) => {
5454
return
5555
}
5656

57-
// force Next to revalidate all ODB revalidation requests so that we always have fresh content...
58-
// setting this header to the preview mode ID is how Next knows to revalidate
57+
// force Next to revalidate all requests so that we always have fresh content
58+
// for our ODBs and middleware is disabled at the origin
59+
// but ignore in preview mode (prerender_bypass is set to true in preview mode)
60+
// because otherwise revalidate will override preview mode
5961
// eslint-disable-next-line no-underscore-dangle
60-
if (headers['x-nf-builder-cache'] === 'revalidate' && !headers.__prerender_bypass) {
61-
console.log(`Revalidating ${url}`)
62+
if (!headers.__prerender_bypass) {
63+
// this header controls whether Next.js will revalidate the page
64+
// and needs to be set to the preview mode id to enable it
6265
headers['x-prerender-revalidate'] = this.renderOpts.previewProps.previewModeId
6366
}
6467

0 commit comments

Comments
 (0)