SvelteKit - Cannot view draft preview

I've successfully configured the preview functionality, but I've noticed that only published content is visible in the preview, whereas the preview is mostly useful for draft content. I'm having difficulty in debugging this issue. Despite being redirected to the preview URL as expected, only published content appears. I would appreciate some help on how to troubleshoot this and ensure that the preview shows draft content as well.

I want to add that I do not see the 'io.prismic.previewSession' in the cookies for my website, but I do see it for the Prismic website.

Maybe this is part of the issue?

I managed to find the solution to the issue. It turned out that our project was utilizing a different, possibly older, version of code for displaying previews. Specifically, our prismicio.js file had the following line:

client.enableAutoPreviewsFromReq(client, cookies);

However, the correct and updated version, as per the documentation, is:

enableAutoPreviews({ client, cookies });

For those encountering a similar problem, it's crucial to strictly follow the documentation. If any code appears different or outdated, replace it with the corresponding snippet from the official documentation to ensure compatibility and proper functionality.

1 Like

Thanks for posting the problem and the solution, @robotkittens!