nextauthjs / nextauthjs/next-auth

Callback dont work with credentials provider (infinite loading)

Open
#9,396 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug providers triage
Dominant language
TypeScript
Stars
28.4k
Forks
4k
PR merge metrics
No merged PRs in 30d

Description

Provider type

Credentials

Environment
"next": "14.0.4",   
"react": "^18",
"next-auth": "^4.24.5"

Windows
Node 20.10.0
Browser: Brave and Chrome
Reproduction URL

https://github.com/omatheusant/ismafer-pages

Describe the issue

I created a simple custom login page using credentials provider to my enterprise webapplication, its working correctly but i'm having a bug that affects the user experience when I try to do the login in my deployment at vercel: https://ismafer-pages.vercel.app/
When I make the login with the right credentials, the page still loading infinite and nevers execute the callback to the "/", but when I reload the page and put the credentials again it works fine and make the push correctly

i try to use the callbackUrl but doesnt work, so I try to use useRouter to make a push and im still having the asme issue.

How to reproduce
  1. Open https://ismafer-pages.vercel.app/ (deploy)
  2. try login with credentials (username: ismafer, password: admin123);
  3. you'll see the loading infinite
  4. refresh the page
  5. try again with the credentials and works correct
Expected behavior

just the callback work correctly at the first time the user try to make the login

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the custom login flow in the reproduction repository and compare its deployed behavior at ismafer-pages.vercel.app with the reported local or first-attempt flow. Trace the credentials sign-in and callback handling, then verify that the first valid login completes navigation to "/" without infinite loading.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, nodejs, react, typescript
Domain
authentication, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.