Sometime in early November, we stopped being able to use Prismic Previews consistently. We believe something is broken on Prismic's side.
Impacted feature
We accept the ref for the prismic preview through a query parameter at /prismic-preview. We're using a custom flow to query the Prismic API. Logging out the queries parameters locally in Node.js, the query parameter for ?token and any from Prismic are missing when we try to accept it server-side. There are no query parameters coming from the Prismic UI.
What steps have you taken to resolve this issue already?
Pulling the app down locally and logging what query params prismic delivers to the client at /prismic-preview. The query parameter is often missing. Sometimes it shows up after some time, but usually no.
Errors
No errors but when we try to use this it's undefined since Prismic isn't delivering the query parameter, so we don't get the preview ref. Also checked to see if Prismic was setting cookies, I don't see those either - though we don't use cookies if they're being set by Prismic (we use our own cookie to keep track of the prismic preview ref).
Your Role
Software engineer
Steps to reproduce
Preview an upcoming unscheduled post in Prismic, go to one of the environments to preview, and usually it won't work.
Thank you for reaching out regarding the issues you’re experiencing with Prismic Previews. I understand how frustrating this must be, and I appreciate the detailed information you’ve provided—it helps us identify potential root causes more effectively.
Based on the description of your setup, it seems you’re using a custom solution for handling Prismic previews and not relying on the default cookie-based system. I’d like to highlight that Prismic’s preview system is fundamentally built on cookies, which are essential for passing the preview token from the Prismic UI to your project. The cookie contains the necessary token to query the REST API for preview information. Without this cookie being received in the browser and subsequently used by your project, the preview functionality cannot work reliably.
Here are our recommendations:
Use Prismic’s Recommended Package:
We highly recommend using one of Prismic’s official SDKs or client libraries to handle previews. These packages are designed to manage the cookie-based preview flow automatically, ensuring compatibility and reducing the likelihood of issues like the one you’re facing.
Verify Cookie Handling:
Even if your project uses a custom cookie for managing the preview ref, you’ll need to ensure the browser still receives the cookie sent by Prismic. This cookie contains the token that enables your application to fetch the preview data. Please confirm whether the Prismic cookie is being set during the preview flow. If not, there may be an issue with how your application or server handles cookies.
Temporary Alignment with Standard Flow:
As a troubleshooting step, consider aligning your project with the standard Prismic preview flow, even temporarily. This will help confirm whether the issue lies with your custom implementation or an external factor.
Double-Check Query Parameter Handling:
It’s worth inspecting any potential redirections or middleware that could be stripping query parameters from the URL during the preview flow.
If you need assistance implementing the standard preview flow or have any further questions, please don’t hesitate to let us know. Additionally, we’re here to help troubleshoot if you encounter further difficulties even after aligning with Prismic’s preview system.