next.js/test/integration/image-optimizer/app/pages/api/conditional-cookie.js
conditional-cookie.js12 lines345 B
const pixel =
  'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPj/HwADBwIAMCbHYQAAAABJRU5ErkJggg=='

export default function handler(req, res) {
  if (req.headers['cookie']) {
    res.setHeader('content-type', 'image/png')
    res.end(Buffer.from(pixel, 'base64'))
  } else {
    res.status(401).end('cookie was not found')
  }
}
Quest for Codev2.0.0
/
SIGN IN