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');
}
});