Prismic previews - Gatsby

Hi all.

I am new to Prismic and would like some clarification on the Gatsby previews. Does a user need to be logged into Prismic to view a Preview at https://preview-mysite.gtsb.io? I would like to think that this would be the case, as it could be a security risk for a user who has the link and could potentially view a page with sensitive content. However, I have also read 'You don't need to have a Prismic account to see the previews' as outlined in this article. Shareable preview: Get a direct link to a page preview and send it to anyone - Prismic

The setup I have built for a Gatsby site seems to only work for content that has been published, and only when a Prismic CMS user is logged in. But, sometimes the preview seems to work even after I have logged out of the CMS (notably with Firefox). Jump to another browser, Safari, and no preview.

Which is the case? Preview when logged in or when someone has the preview link? I have followed the steps and have used 'V4 of our Gatsby + Prismic integration'.

Thanks

Just seen the note on Safari cross-site tracking, so ignore Safari comment.

Hi Peter,

Welcome to the Prismic community!

So as you said Previews only work for logged in Prismic users.

They function by using browser cookies. The Prismic dashboard generates the cookies in your browser and passes in in your browser's tabs to the correct place, this is why only the current user can see it and you don't see it in another browser.

When you create a shareable link you create a link that can fetch the cookie and allow any users with that link to see the Preview in their browser.

If you are seeing unpublished content then you likely need to load the preview script in your 404 or update your linkresolver as described here:

Does this clarify things for you?

Thanks.

Thanks, Phil. Perfect explanation!

1 Like

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