nextauthjs / nextauthjs/next-auth
Error: `headers` was called outside a request scope, when using Authjs v5.0.0-beta.19 and next dev --turbo
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28.4k
- Forks
- 4k
- PR merge metrics
- No merged PRs in 30d
Description
Environment
System:
OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1265U
Memory: 5.33 GB / 15.47 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 22.0.0 - ~/.nvm/versions/node/v22.0.0/bin/node
npm: 10.5.1 - ~/.nvm/versions/node/v22.0.0/bin/npm
npmPackages:
@auth/drizzle-adapter: ^1.2.0 => 1.2.0
next: ^14.2.3 => 14.2.3
next-auth: ^5.0.0-beta.18 => 5.0.0-beta.19
react: ^18.3.1 => 18.3.1
Reproduction URL
https://github.com/cogb-jclaney/authjs-issue
Describe the issue
When running a Next JS site using Authjs v5.0.0-beta.19 and next dev --turbo, I get the following error - "Error: headers was called outside a request scope", running next dev without the --turbo flag works as previous.
Authjs v5.0.0-beta.18
next dev (works)
next dev --turbo (works)
Authjs v5.0.0-beta.19
next dev (works)
next dev --turbo (causes the error)
How to reproduce
Running the command "npm run dev" when "--turbo" is enabled cause the application to error.
Running the command without "--turbo" works normally and both with and without work on the previous version (v5.0.0-beta.18).
Credential provider has been configured for the example, no inputs actually needed, user has been hardcoded.
Expected behavior
The session from "await auth()" should be returned.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction repository and run its npm run dev command with and without --turbo. Compare Authjs v5.0.0-beta.18 and beta.19 under Next.js 14.2.3, focusing on the reported headers request-scope error. Done means await auth() returns the session in turbo development mode without the error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, nodejs, typescript
- Domain
- authentication, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100