Prismic preview 404 CDN

Hi!

We are encountering an issue lately with the Preview process. It was working well end suddenly stopped working.

The site is not up to date regarding prismic dependencies, we are using prismic-javascript@2.1.4 et prismic-reactjs@1.1.2. We use the deprecated method Prismic.client().previewSession().

On some pages we get an “Internal Server Error” when trying to access a draft preview. Here is the error message we are getting: "Unexpected status code [404] on URL https://repo.cdn.prismic.io/api/v2/documents/search?page=1&pageSize=1&lang=fr-fr&ref={"_tracker"%3A"2KX1knSE"%2C"repo.prismic.io"%3A{“preview”%3A"https%3A%2F%2Frepo.prismic.io%2Fpreviews%2FXx6snBAAAL1uTip_%3AXx7w7hAAAL1uT11r%3FwebsitePreviewId%3DXkLNpxMAAPuqqU0T"}}&q=[[at(document.type%2C%20"menu")]]”

I took the liberty to remove the name of our actual repository and wrote “repo” in its place. The error stacktrace points to the prismic-javascript library.

Did anything change on Prismic’s side?

Thanks for your help.

Hi Jonas,

Welcome to Prismic community, I will try to help you on this.
I’m checking with our dev team if there has been any changes in the codebase that broke the deprecated Prismic.client().previewSession() .

I will let you know once I have some info,

Fares

Hi Fares,

Thank you for your help. I’m looking forward to what you’ll find.

Have a good day.

Regards,
Jonas.

Hi,

I have the same problem.

Everything works properly in development, in production already published content works fine but the preview link for unpublished content ends up in a 404 (with the good preview url though…).

Hi Floran,

It sounds like you haven’t got the preview script enabled in your 404 page as well, it needs this to redirect correctly. We discuss this in the preview troubleshooting document:


Thanks.

Hi !

No, it was correctly included. I’ve just solved it !!

In NextJs, you need to have fallback : true in getStaticPaths or it will always render a 404. It doesn’t happen in development because getStaticPath is rerendered every time !

2 Likes

Awesome, I’ll check if we need to update our docs to include this info.

Glad you found your solution @fcosnier.

We are not using getStaticPaths in our project so I doubt that this solution apply to the problem I mentioned earlier. We use getInitialProps to fetch our data as we’re using next@9.1.6.