Skip to content

Instantly share code, notes, and snippets.

@erwan
Last active August 29, 2015 14:09
Show Gist options
  • Save erwan/ee4c46bcc635829e286f to your computer and use it in GitHub Desktop.
Save erwan/ee4c46bcc635829e286f to your computer and use it in GitHub Desktop.
// Example preview endpoint for NodeJS with ExpressJS
exports.preview = exports.route(function(req, res, ctx) {
var previewToken = req.query['token'];
ctx.api.previewSession(previewToken, ctx.linkResolver, '/', function(err, redirectUrl) {
res.cookie(Prismic.previewCookie, previewToken, { maxAge: 60 * 30, path: '/', httpOnly: false });
res.redirect(redirectUrl);
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment