next-auth: "UnhandledPromiseRejectionWarning: TypeError: Cannot read property '0' of undefined" error when connecting to http://localhost:3000/api/auth/signin
Your question UnhandledPromiseRejectionWarning: TypeError: Cannot read property ‘0’ of undefined when visiting http://localhost:3000/api/auth/signin
What are you trying to do I’m trying to set up a simple user authentification with MongoDB following this tutorial - https://blog.logrocket.com/using-authentication-in-next-js/ Getting the below error when visiting http://localhost:3000/api/auth/signin
Similar to this issue - https://github.com/nextauthjs/next-auth/issues/636
I checked the filenaming and dir

Full error below
Thanks in advance for any help!
(node:15228) UnhandledPromiseRejectionWarning: TypeError: Cannot read property ‘0’ of undefined
at C:\Users\simon.edge\PROJECTS\FromGrave\nexts-blog\node_modules\next-auth\dist\server\index.js:68:28
at Generator.next (<anonymous>)
at asyncGeneratorStep (C:\Users\simon.edge\PROJECTS\FromGrave\nexts-blog\node_modules\next-auth\dist\server\index.js:48:103)
at _next (C:\Users\simon.edge\PROJECTS\FromGrave\nexts-blog\node_modules\next-auth\dist\server\index.js:50:194)
at C:\Users\simon.edge\PROJECTS\FromGrave\nexts-blog\node_modules\next-auth\dist\server\index.js:50:364
at new Promise (<anonymous>)
at C:\Users\simon.edge\PROJECTS\FromGrave\nexts-blog\node_modules\next-auth\dist\server\index.js:50:97
at C:\Users\simon.edge\PROJECTS\FromGrave\nexts-blog\node_modules\next-auth\dist\server\index.js:342:22
at new Promise (<anonymous>)
at C:\Users\simon.edge\PROJECTS\FromGrave\nexts-blog\node_modules\next-auth\dist\server\index.js:58:12
at Generator.next (<anonymous>)
at asyncGeneratorStep (C:\Users\simon.edge\PROJECTS\FromGrave\nexts-blog\node_modules\next-auth\dist\server\index.js:48:103)
at _next (C:\Users\simon.edge\PROJECTS\FromGrave\nexts-blog\node_modules\next-auth\dist\server\index.js:50:194)
at C:\Users\simon.edge\PROJECTS\FromGrave\nexts-blog\node_modules\next-auth\dist\server\index.js:50:364
at new Promise (<anonymous>)
at C:\Users\simon.edge\PROJECTS\FromGrave\nexts-blog\node_modules\next-auth\dist\server\index.js:50:97
(node:15228) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 10)
Reproduction
Feedback Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.
- Found the documentation helpful
- Found documentation but was incomplete
- Could not find relevant documentation
- Found the example project helpful
- Did not find the example project helpful
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (8 by maintainers)
Ahhh, annoying! Thank you for spending the time to help @balazsorban44 It’s always something stupid…right?!
Yeah…but brackets then replaces the … with … automatically. I had to rename the file outside of brackets.io to get it to work
All working now! Thanks again
FYI it’s a brackets.io thing that caused it
You will be mad, but I found the issue… 😅 The filename was wrong! Bad:
[…nextauth].jsGood:[...nextauth].jsThe
…character is not equal to three.characters, and therefore Next.js (so not actuallynext-auth) could not group the url path segments into an array, and that’s why you got the above error.Simply change
…to...and it should work!Additionally, remove
options={{ site: process.env.SITE }}frompages/_app.js, it does nothing. Unfortunatelly the blog post you looked at seems to be outdated in certain things. 😕 If you have the opportunity to contact the autor, please send them to this issue, or tell them to contact us directly.(For security reasons, I also recommend you removing me from accessing your repo 😉)
Yep - https://github.com/sunrunner4kr-simon/FromGrave I’ve sent you an invite
Thanks