Preview error (expired token)

Same problem with @nuxtjs/prismic. Was working hour ago and now all previews end up with this error:

ERROR  Unexpected status code [404] on URL https://[repository].cdn.prismic.io/api/v2/documents/search?[searchParams]

  at node_modules/prismic-javascript/dist/prismic-javascript.min.js:1:16437
  at runMicrotasks (<anonymous>)
  at processTicksAndRejections (internal/process/task_queues.js:97:5)

Hey @Phil, sorry for late response but I didn’t get any notifications (now fixed, I’ve turned them on) and also had no time to work on this issue. From my experience it’s working for few first times, and after 10 or 20 previews it starts to get this error. I think it could be connected with rate limiting for an account, because it doesn’t matter if I preview locally or on production site.

My code is forked from this template.

Unfortunately but after 18hrs previews still doesn’t work. One thing I found out now, is that I get this warning before previously showed error:
WARN previewSession function is deprecated in favor of getPreviewResolver function.
Also if I try to manually visit URL that Unexpected status code [404] on URL error gives me I get:

{
"error": "This preview token has expired",
"oauth_initiate": "https://[repository].cdn.prismic.io/auth",
"oauth_token": "https://[repository].cdn.prismic.io/auth/token"
}

If you want I can send you full preview token in pm.

Also found out that preview DO work if the site is static generated - so error occurs only with SSR.

Hey,

The warning for the getPreviewResolver deprecation shouldn't cause this issue.

So for this error:

The preview token expires once the saved information has been archived or published. The preview token generated is only valid for the information being previewed at that time. This would suggest that your trying to use an old link after the content has been changed.

Are you making sure that your are clearing the cookies when you finished by clicking the ‘X’ button on the preview module to exit the preview? If you forget to do this the cookies might not be cleared and so your web browser can receive old preview data.

Edit: I moved this to a new topic as the original thread was not the correct place.

1 Like

Okey, that was the issue. Manually clearing cookies resolved it.
Still, don’t know why this happend when I was clicking preview button every time from prismic app, not using old links.

It can be easy to forget to exit the preview, it happens. Glad we resolved this.

For anyone else in the future we discuss this and other issues in the preview troubleshooting document.