You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently working on integrating authentication using NextAuth.js with a custom backend API. I've successfully implemented the login functionality using the CredentialsProvider, but I'm facing an issue when it comes to displaying error messages from the API.
How can I capture and display the exact error message provided by the API in the UI when the sign-in fails? I'm not sure how to catch it and display it in the frontend.
Any guidance or example code would be greatly appreciated!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I'm currently working on integrating authentication using NextAuth.js with a custom backend API. I've successfully implemented the login functionality using the CredentialsProvider, but I'm facing an issue when it comes to displaying error messages from the API.
You can find my complete project repository here: Next.js NextAuth Kit.
Question:
How can I capture and display the exact error message provided by the API in the UI when the sign-in fails? I'm not sure how to catch it and display it in the frontend.
Any guidance or example code would be greatly appreciated!
Thanks in advance!
Here is my current configuration:
And in my sign-in function:
Beta Was this translation helpful? Give feedback.
All reactions