UNPKG

next-cookies

Version:
14 lines (11 loc) 498 B
var Cookies = require("universal-cookie"); // we seem to sometimes get the ES6 version despite requesting cjs here, not sure why // this isn't the ideal fix, but it'll do for now Cookies = Cookies.default || Cookies; function nextCookies(ctx, options) { // Note: Next.js Static export sets ctx.req to a fake request with no headers var header = ctx.req && ctx.req.headers && ctx.req.headers.cookie; var uc = new Cookies(header); return uc.getAll(options); } module.exports = nextCookies;