Hi everyone
I have been having a little bit of struggle with the preview mode. To fetch the unpublished posts, we would need to preview ref, and this is how it is done on the Prismic's NextJS page:
const Preview = async (req, res) => {
const { token: ref, documentId } = req.query;
const redirectUrl = await Client(req)
So within req.query
, there should be token, within which I would find the ref
and the documentID
. In my case, token
does not have any items inside it. It is a string. Something similar to this:
https://example-repository.prismic.io/previews/XzjsUxJFIEKGAAAK:XzfX3BVHSOWAzIaf?websitePreviewId=GKHCDOBLDJW
Is there a reason for that? Currently I am fetching the preview string from the prismic cookie that prismic's preview library script automatically adds. But I would love to do it without it and take it right from the query.