CSRF Problem on NextJs 13.4 #7785
-
Question 💬I do check next-auth with NextJs v12 and v13 separately, as you may know, v12 uses the pages directory and v13 uses the app directory. next-auth sign-in works perfectly on v12 but not on v13.
I will appreciate any answers ❤️ How to reproduce ☕️Install a new Nextjs project and next-auth beside it.
run the development server: Contributing 🙌🏽Yes, I am willing to help answer this question in a PR |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 6 replies
-
There seems to be an issue reading request headers in node 18 + nextJS 13 on the GET route handler. See here. I believe next-auth is failing to read the request cookies due to an issue in nextjs, therefore it is unable to validate the csrf token and redirects to the sign in page with a new csrf token. Updating my node version from v18.1.0 to v20.4.0 resolved the issue for me 🎉✨. |
Beta Was this translation helpful? Give feedback.
-
I upgraded to v20.6.0 and I still see the same issue. |
Beta Was this translation helpful? Give feedback.
-
after a long time of headache. it works when upgrading to node v20.7.0 |
Beta Was this translation helpful? Give feedback.
-
I am on Node: v21.6.1 and Next js: 14. Should I be downgrading to make it work? :( |
Beta Was this translation helpful? Give feedback.
-
Since, it's a CSRF error the most possible cause is due cross-site integration. If you have your |
Beta Was this translation helpful? Give feedback.
-
removing NEXTAUTH_URL from my env file solve my issue |
Beta Was this translation helpful? Give feedback.
after a long time of headache. it works when upgrading to node v20.7.0