I get this weird error sometimes from the API - This preview token has expired

As the title says i somehow get this error from the API.

{"type":"api_notfound_error","message":"{%22_tracker%22:%22o6uApCO3%22%2C%22toposhopy.prismic.io%22:{%22preview%22:%22https://toposhopy.prismic.io/previews/YtU5XREAAB4AdES3:Ytvu1xAAACAAtSrz?websitePreviewId=YlR0UBMAACQAF081%22}} not found"}

Do you guys have any idea of how to troubleshoot and find this error?

I get it on server side (node.js + express) when i try to make a request to get some kind of config / posts.

Bellow is a sample code on where the error occurs. Specifically on the awair promise all

let podcastsPromise = client.getByType('podcast', {
pageSize: 1,
// Get config
let configPromise = client.getSingle('config');
let [cases, insights, podcasts, config] = await Promise.all([

Hello @akumanara

Thanks for reaching out to us.

I need more information:

  • Have you tried refreshing the page?
  • Which technology are you using in your project, and how did you configure the previews?


Hi @Priyanka

Thanks for the response.

Refreshing the page does not help.

I use express js and i took the preview part from your examples.

I see in your examlpes you have 2 ways for the preview route. Can you clarify which is the correct?

Way 1

Example taken from: nodejs-blog/app.js at c634f9ed77b76b9320d3afb041b0d066a25cac86 · prismicio/nodejs-blog · GitHub

asyncHandler(async (req, res, next) => {
const redirectUrl = await client.resolvePreviewURL({ defaultURL: '/' });
res.redirect(302, redirectUrl);

Way 2

Example taken from: nodejs-multi-language-site/app.js at 32833ffc5162b330e11779482775b8ea33ff7db7 · prismicio/nodejs-multi-language-site · GitHub

// Prismic preview route
app.get('/preview', asyncHandler(async (req, res, next) => {
const { token, documentId } = req.query;
const redirectUrl = (await req.prismic.api.getPreviewResolver(token, documentId).resolve(prismicConfig.linkResolver, '/'));
res.redirect(302, redirectUrl);
res.status(500).send(Error 500 in preview);
res.send(400, 'Missing token from querystring');

Thanks in advance

Hello @akumanara

With the latest version of @prismicio/client v6, the first way of the preview route is good. You can also check our Preview Draft guide.

Let us know if you need any help.