Next.js Discord

Discord Forum

Issues with login / fetching user session (Please test for yourself if you can!)

Unanswered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
Hey guys currently I'm using next auth / mongoDB to manage login and user sessions for my site. I have a feature on my site where it checks whether or not the user is logged in before allowing them to visit the videos, favorites, etc page. If they're not logged in then it redirects them to sign in page.

For most accounts this is working but for some (mostly accounts where I purchases credits) it constantly sends me back to sign in page even when I'm already logged in. Something odd is that some accounts work when I run on localhost but not through vercel and vice versa.

I checked my run logs and see this error message once it redirects but I'm not sure what it means:

[next-auth][error][CLIENT_FETCH_ERROR] 
https://next-auth.js.org/errors#client_fetch_error fetch failed {
  error: {
    message: 'fetch failed',
    stack: 'TypeError: fetch failed\n' +
      '    at Object.fetch (node:internal/deps/undici/undici:11457:11)',
    name: 'TypeError'
  },
  url: 'https://adsreveal-main-k1hgdsetv-jonahgoldfink-gmailcom-s-team.vercel.app/api/auth/session',


Please feel free to test yourself at https://app.adsreveal.com/ with these test account credentials:

Email: nftrackracing@gmail.com
Password: Jonahtest123

You should be able to easily re-create the issue by logging in, clicking the videos tab and it will redirect you back to login in a loop. I'm super stuck on this so any insight would help!

Also let me know if you need any code, logs, etc I would be happy to provide.

0 Replies