I’m using NextJS with Sanity.io on https://mambu-rebuild.netlify.app/ (Live site: https://www.mambu.com/). We have preview set up in accordance with the NextJS/Sanity demo (next.js/examples/cms-sanity at canary · vercel/next.js · GitHub). It was working up until last Friday but stopped at the beginning of this week. We did a bunch of work towards the end of the week/early this week and so I initially assumed we had changed something to cause it to break and rolled back to a prior commit before all the potentially breaking changes. However, I expected that the preview would start working again once rolled back and it hasn’t. This is a quick run down of my experience in case anyone has any ideas that might help identify the problem:
Hitting the preview api route sets __prerender_bypass & __next_preview_data cookies as expected and redirects correctly;
However, despite the cookies being set preview mode does not kick in and therefore live updates do not show;
The preview variable logs false in getStaticProps;
We are using the next essentials plugin and have set the next.config.js target to ‘serverless’;
Everything works perfectly on my local server i.e. the cookies are set, the app enters preview mode and all live updates are visible.
The cookies are being set as HttpOnly, Secure, SameSite=None. I initially suspected that one of these settings might be the cause but manually manipulating those cookies in the api preview function did not help;
UPDATE: I just tested our site and it seems to be working once again as of 04/30 6.20am PST. Yesterday before it stopped working for good, I noticed a similar spotty behavior throughout the day. I will report again throughout the day today.
We are experiencing the same issue. For us, it seems to have started yesterday despite no code changes or package updates either on nextjs or next-on-netlify.
We are seeing both nextjs cookies being set and the redirect work, but preview is coming as undefined on getStaticProps. This problem is only happening in production. Preview mode works fine in both development mode and in local production when running and serving a local build via netlify build.
We have since tried, upgrading next-on-netlify to 3.2.0 which did not help. We also tried going back a few days to deploys we know were 100% working and these are now not working either.
I have a feeling that this issue could be related to this other issue function cookies, but thats just a wild guess.
This issue is concerning as we were about to go live net week with a new project.
the good news is we were able to roll out a fix for this issue, and we understand the cause of the problem, so this should not happen again. This explains why you saw some issues that were then mysteriously fixed (its cause we fixed 'em~)
if you do see problems like this re-occur, please do let us know right away and we will investigate, but we feel confident this was a one-time thing.
thanks for the explanation @perry! much appreciated. We were going crazy thinking it was something we had done at our end.
So, today we certainly saw some improvement compared to yesterday, but we did have some odd behaviors this afternoon (PST). Things seems to be working at the moment, but it would be great to get some reassurance that you guys are still monitoring this issue.
Welcome to the Netlify Forums! Thanks so much for reaching out about this.
Are you still encountering this issue? If so, can you please share your repo as well as an update of the debugging steps you have taken so far? Thank you
Open deployed version of the repository https://kontent-starter-corporate-next-js.netlify.app/
Access the /api/preview endpoint with secret key (there are no sensitive information): https://kontent-starter-corporate-next-js.netlify.app/api/preview?secret=netlify_secret
Cookies are __next_preview_data and __prerender_bypass are set, but the preview data are not visible (there should be a preview bar and the background of the site should be cyan instead of orange see https://github.com/Kentico/kontent-starter-corporate-next-js#enter-the-preview for more information)
Thanks for your patience here. I want to assure you we have not forgotten about your question-- I am meeting with our NextJS experts tomorrow and they will dive in further. Thanks!
Can you please try installing the plugin and redeploying? The plugin is out now as 3.8.0. We believe that this should do the trick, but please let me know how it goes or if you have any further questions