JWT is null only in middleware
See original GitHub issueEnvironment
System: OS: macOS 12.4 CPU: (10) arm64 Apple M1 Max Memory: 1.25 GB / 32.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.14.0 - ~/.volta/tools/image/node/16.14.0/bin/node Yarn: 1.22.18 - ~/.volta/tools/image/yarn/1.22.18/bin/yarn npm: 8.3.1 - ~/.volta/tools/image/node/16.14.0/bin/npm Browsers: Brave Browser: 103.1.41.100 Chrome Canary: 106.0.5216.0 Firefox: 103.0 Safari: 15.5 npmPackages: next: 12.2.3 => 12.2.3 next-auth: ^4.10.3 => 4.10.3 react: 18.2.0 => 18.2.0
Reproduction URL
https://github.com/unredundant/next-auth-middleware-bug-repro
Describe the issue
Token is always null in middleware when using github auth 😦
How to reproduce
Copy the .env.local.example
and populate with github app credentials.
Start the app then sign in with github
If you go to /admin
or anything that is protected by middleware, you will see that the token
is null. However, go to the /api/examples/jwt
page and you will see that the token is there

Expected behavior
middleware should be able to get the existing token
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
ah yep @dgrcode a full wipe of node modules did the trick, gonna close in favor of the other ticket, thanks all 🙏
@unredundant I had to remove node_modules, yarn.lock/package.lock, and reinstall everything with npm.
You might be able to get things working reinstalling dependencies with yarn, but I switched to npm because it was acting up.