Next.js Discord

Discord Forum

NextAuth: no redirect and server action error "A React form was unexpectedly submitted."

Unanswered
Cape lion posted this in #help-forum
Open in Discord
Cape lionOP
Hi, I'm encountering the errors described here
https://github.com/vercel/next.js/discussions/56234
and here
https://github.com/nextauthjs/next-auth/issues/10016
on the Logout button similar to the tutorial here
https://nextjs.org/learn/dashboard-app/adding-authentication

specifically, on login, there is a dashboard/ route with layout.tsx that includes a NextAuth.js form with a signout button. here's the full source
https://github.com/ransomw/search-matrix-nextjs/tree/nextauth-diff

---

Observed:
after login at /login with user b@b.org and password password, the dashboard does display in the rendering engine. the url bar does not update like in 10016 above after login, and the logout button doesn't work, because the form action is set to the error message in 56234 above.
Reloading the page both updates the url bar (from /login to /dashboard) and allows the logout button to work.

Expected:
after login the dashboard loads, the url bar updates, and the logout button works without a page reload.

---

it is very similar to the NextJS dashboard-app tutorial from linked above, except pared down to just the login functionality and using pg instead of vercel/postgres. i have tried making the app as small as possible based on the tutorial and added debugging statements to the redirects.

i have tried spotting the difference between the dashboard-app tutorial, but i don't see it. and i don't have enough knowledge about how NextJS server actions and NextAuth work behind the scenes to debug based on the behavior.

0 Replies