Trouble with preview mode in Next.js

I have Preview mode set up in a Next.js as per the Prismic example.

So far as I can tell, I have everything configured correctly and yet Next.js will only load dynamic routes in preview mode on the first request of that page. After the page has been requested outside of Preview mode, it's no longer possible to view the page in preview mode again.

1. From the Prismic Editor UI, the user clicks on the Preview button which redirects to`

2. Prismic then redirects to

3. The api/preview endpoint then gets the redirectUrl from Prismic and redirects to /redirectUrl, setting the Next.js preview cookies.

set-cookie: __prerender_bypass=391b9dd5be2db3f82d091836f424ccd3; Path=/; HttpOnly; Secure; SameSite=None

set-cookie: __next_preview_data=eyJhbGciOiJIUzI1NiIsInR5c...; Path=/; HttpOnly; Secure; SameSite=None

I am able to load the page in preview mode immediately after deploying and rebuilding the app to the server (Digital Ocean App Platform). However, if I leave Preview mode and load the page again, I am no longer able to view it in Preview Mode afterwards. Successive attempts redirect me to the correct page with the cookies set, but without getStaticProps getting called.

I thought this might be an issue with getStaticProps in Next.js and opened up this issue a few days ago.

Any help with this would be hugely appreciated!

Did some digging and think this results from aggressive caching in Next.js. Opened this issue which should hopefully fix it.


Figured it out. Solution here for anyone who runs into a similar situation:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.