Preview works on localhost, but not in production

Hi Prismic community!

I try to use Previews within my Next.js & Prismic project. It works on the localhost environment but not in production, where a 404 page – which is constantly reloading – is shown instead of the preview page.

I tried to implement everything as it is described in the documentation and tried to debug by reading in this forum.

Reading the thread Troubleshooting: Previews I found two aspects which were confusing:

  1. It describes that the previews script has to be in the head of every page, but it is located in the body of all my pages. Is this also okay?

  2. it describes that the preview cookie should look something like this:

...but when I inspect the cookie in the preview it looks like this:

Some context info: The project uses

The project is not using slice machine, what makes it a little bit difficult, because all the documentation is based on projects which use slice machine.

I know that there are many more aspects, which could be relevant to figure out what is the reason why my preview does not work yet. Please ask if I should give some specific context info!

I'm very thankful for every help!

Hey @yaay, Thanks for sharing your use case. It helps us improve the documentation. I've modified the troubleshooting doc to be more precise.

  1. The Prismic preview toolbar script can be anywhere on your pages, but we usually recommend placing it before the end of the <body> tag for readability and semantics.
  2. On Prismic (your repository), you have .previewSession which looks like this YrRvNBEAACwARCrR~YmAK0xIAACkAGxPJ when on a preview session. On your website, you have .preview, which looks like a JSON object when in a preview:

The important one to look for is the one on your website.

Have you followed the preview guide in Next?