0

Couldn't find a result from browsing. I keep getting this error, although it worked fine when I first built this app, I can't get through authentication in deployed app as well as different machines. It says that it can't find [...nextAuth].js although it's there. Think you guys can help?

[next-auth][error][MISSING_NEXTAUTH_API_ROUTE_ERROR]
https://next-auth.js.org/errors#missing_nextauth_api_route_error Cannot find [...nextauth].{js,ts} in /pages/api/auth. Make sure the filename is written correctly. MissingAPIRoute [MissingAPIRouteError]: Cannot find [...nextauth].{js,ts} in /pages/api/auth. Make sure the filename is written correctly.
    at assertConfig (C:\Users\ahadh\Desktop\tail-tale\node_modules\next-auth\core\lib\assert.js:21:12)
    at NextAuthHandler (C:\Users\ahadh\Desktop\tail-tale\node_modules\next-auth\core\index.js:34:52)
    at NextAuthNextHandler (C:\Users\ahadh\Desktop\tail-tale\node_modules\next-auth\next\index.js:21:51)
    at C:\Users\ahadh\Desktop\tail-tale\node_modules\next-auth\next\index.js:57:38
    at Object.apiResolver (C:\Users\ahadh\Desktop\tail-tale\node_modules\next\dist\server\api-utils\node.js:184:15)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async DevServer.runApi (C:\Users\ahadh\Desktop\tail-tale\node_modules\next\dist\server\next-server.js:381:9)
    at async Object.fn (C:\Users\ahadh\Desktop\tail-tale\node_modules\next\dist\server\base-server.js:491:37)
    at async Router.execute (C:\Users\ahadh\Desktop\tail-tale\node_modules\next\dist\server\router.js:213:36) {
  code: 'MISSING_NEXTAUTH_API_ROUTE_ERROR'
} 

Image Errors | NextAuth.js This is a list of errors output from NextAuth.js. if anyone can help I would love to share the GitHub repo.

juliomalves
  • 42,130
  • 20
  • 150
  • 146
  • Can you share your `pages` folder structure? The file needs to be named exactly the same as the error mentions: `/pages/api/auth/[...nextauth].js`. Make sure the casing is right, and not `[...nextAuth].js`. – juliomalves Aug 07 '22 at 18:14

2 Answers2

0

I fixed it. Change your file name, and execute 'npm run build'. after restart server. clear.

  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 30 '22 at 23:28
0

finally, i found it. your files name would be [...nextauth]. [jsx or tsx.] rename to [js or ts]