question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JWT is null only in middleware

See original GitHub issue

Environment

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

Screen Shot 2022-08-03 at 12 49 24 PM

Expected behavior

middleware should be able to get the existing token

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
unredundantcommented, Aug 3, 2022

ah yep @dgrcode a full wipe of node modules did the trick, gonna close in favor of the other ticket, thanks all 🙏

0reactions
dgrcodecommented, Aug 3, 2022

I tried that with no luck 😦 guess i could give it another go

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Laravel middleware api always return null even with the ...
But when i write the request code in the controller it always return null $token = 'abcde'; $request = Request::create('/api/user', 'GET', ...
Read more >
A look behind the JWT bearer authentication middleware in ...
In this post we look at the JwtBearerAuthenticationMiddleware as a means to understanding authentication in ASP.NET Core in general.
Read more >
Spring Boot Security + JWT Hello World Example - JavaInUse
We will be generating a JWT and allowing access only if the header has a valid JWT. ... String jwtToken = null; //...
Read more >
passport-jwt
jwtFromRequest (REQUIRED) Function that accepts a request as the only parameter and returns either the JWT as a string or null. See Extracting...
Read more >
REST Security with JWT using Java and Spring Security - Toptal
JWT (shortened from JSON Web Token) is the missing standardization for using tokens to authenticate on the web in general, not only for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found