Hello,
I am building a NextJS site with data from Contentful and hosting on Netlify. I am trying to allow content editors in Contentful to view a preview of an entry before they publish it. I have followed this guide from NextJS and their Contentful example. I have successfully set up the preview mode in my local environment.
I think that what I need to do to allow the same functionality on the Netlify hosted site is create the equivalent api route in NextJS (/api/preview
) in a Netlify function. Then I need to set the same cookies that this api route (/api/preview
) sets using the method
res.setPreviewData({})
In my Netlify function.
So my questions are:
- Is the the correct way of going about this?
- If so, could someone point me in the direction of how I should go about setting the
setPreviewData({})
cookies if the Netlify function does not have the same syntax as Next. e.g. Next:
export default async function preview(req, res) {
And Netlify functions (no res
object)
exports.handler = async function preview(event, context) {
Thank you