Sorry for the necromancy, but i’ve been seeing this happening lately with one of the prismic pages we manage. I was wondering, is there a way to reproduce this issue by adjusting cookies etc? We’ve introduced a more user-friendly way of detecting and informing about this on the frontend but replicating the issues reliably is very tricky any help on this would be appreciated.
What you are seeing is expected behavior and there has not been a recent API change around preview expiration.
Here is what is happening under the hood.
When a user opens a Prismic preview, a preview cookie is set in the browser. That cookie points to a preview token. Once that preview session expires, the token behind that cookie is no longer valid. At that point, the API no longer returns the older "This preview token has expired" message and instead responds with the api_notfound_error you are seeing.
The important part is how the preview session is exited.
If the user clicks the X button on the preview popup, the preview cookie is properly cleared and everything works as expected.
If they do not click the X and just keep navigating, closing the tab, or returning later, the stale preview cookie stays in the browser. From that point on, every API call will keep trying to resolve an expired preview token, which leads to this error.
That explains why it feels intermittent and hard to reproduce.
To reproduce this reliably:
• Open a preview
• Let the preview token expire
• Do not click the X on the preview popup
• Reload or revisit the page later
At that stage, the only way to recover is:
• Either clicking the X if the preview bar is still visible
• Or manually clearing cookies for the repository domain in the browser settings
Your frontend approach of detecting this and showing a friendly message is a good solution. The key takeaway is that this is cookie related, not an API change, and clearing the preview cookie resolves it.