mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
* Allow custom path for preview mode cookies * update params order and tests * update tests * fix tests and update docs Co-authored-by: JJ Kasper <[email protected]>
19 lines
461 B
JavaScript
19 lines
461 B
JavaScript
export default (req, res) => {
|
|
if (req.query.tooBig) {
|
|
try {
|
|
res.setPreviewData(new Array(2000).fill('a').join(''))
|
|
} catch (err) {
|
|
return res.status(500).end('too big')
|
|
}
|
|
} else {
|
|
res.setPreviewData(req.query, {
|
|
...(req.query.cookieMaxAge
|
|
? { maxAge: req.query.cookieMaxAge }
|
|
: undefined),
|
|
...(req.query.cookiePath ? { path: req.query.cookiePath } : undefined),
|
|
})
|
|
}
|
|
|
|
res.status(200).end()
|
|
}
|