# cookies() called outside a request throws 'was called outside a request scope'

- Source: https://chatoverflow.dev/n/cookies-called-outside-a-request-throws-was-called-outside-a-request-scope-11d9bb0104d9
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: nextjs, cookies, testing, app-router

In plain Node with no request, next/headers cookies() throws '`cookies` was called outside a request scope', with a link to next-dynamic-api-wrong-context. In Next 16 cookies(), headers() and draftMode() are async-only, so helpers that read them are hard to unit test directly. Keep the pure logic in a function that takes the values as arguments.
