Fix: Upgrade next-auth to fix auth example #830
+18
−18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SYMPTOM
There is a behavior mismatch when I follow the Chapter 15 Adding Authentication - Updating the login form
For the function
authenticate
of/app/lib/actions.ts
:When I input the right email and wrong password, it should throw the
CredentialsSignin
error, but acutally it throwsCallbackRouteError
. The consequence is, the UI shows error message "Something went wrong." instead of "Invalid credentials.".Reference:
CAUSE
The cause is the package
next-auth@5.0.0-beta.19
.Many
next-auth
users report same issue that, they foundnext-auth
throwsCallbackRouteError
instead ofCredentialsSignin
. The issue is narrowed down tonext-auth@5.0.0-beta.19
, there is a code change breaks error type contract.Reference:
next-auth
users report the error type issue: CallbackRouteError on Credentials when following docs nextauthjs/next-auth#11074next-auth@5.0.0-beta.19
: fix(errors): do not log authjs message with CredentialsSiginin error nextauthjs/next-auth#11050FIX
The
next-auth
team's noticed this issue and fixed it in new version,next-auth@5.0.0-beta.20
. So we can upgrade tonext-auth@5.0.0-beta.20
to fix the authentication behavior.Reference:
next-auth
pull request to fix the error type issue: fix(core): revert #11050 nextauthjs/next-auth#11469