Preview always goes to homepage

I've set up previews as per the docs but it always lands on the homepage. The docs state I need to include the code below but I'm not quite sure where I am supposed to put the code?

app.get('/preview', (req, res) => {
  const token = req.query.token;
  if (token) {
    req.prismic.api.previewSession(token, PrismicConfig.linkResolver, '/').then((url) => {
      res.redirect(302, url);
    }).catch((err) => {
      res.status(500).send(`Error 500 in preview: ${err.message}`);
    });
  } else {
    res.send(400, 'Missing token from querystring');
  }
});

Hello Tim Diacon,

Welcome back to the Prismic forum.

Are you using nuxt.js framework? If so, you need to follow this documentation. You don't need to put the above code anywhere in the nuxt project.

Let me know if the documentation works for you.

Thanks,

Priyanka

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.