Skip to content

Commit 7e9413f

Browse files
committed
chore: add previewMode to middleware demo
1 parent 3807bcb commit 7e9413f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default async function preview(req, res) {
2+
// Enable Preview Mode by setting the cookies
3+
res.setPreviewData({})
4+
5+
res.status(200).json({ name: 'preview mode' })
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default async function exit(_, res) {
2+
// Exit the current user from "Preview Mode". This function accepts no args.
3+
res.clearPreviewData()
4+
5+
// Redirect the user back to the index page.
6+
res.writeHead(307, { Location: '/' })
7+
res.end()
8+
}

0 commit comments

Comments
 (0)