NextAuth error on production

I’ve completed the NextJS course, and my authentication works fine locally, but when I try to login on my Vercel environment I get errors.
I’ve created a new client for production on google:

I’ve added the GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET to my environment variables in Vercel.
My code is located at app/api/auth/[…nextauth]/route.ts as described in the course.

When I try to go to my login page at https://issue-tracker-beta-eight.vercel.app/api/auth/signin

I get an error message saying

“There is a problem with the server configuration. Check the server logs for more information.”

In the logs I see

[GET] /api/auth/session?nxtPnextAuth=session status=500

I also see 1 second later, this log:

[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. r [MissingAPIRouteError]: Cannot find [...nextauth].{js,ts} in `/pages/api/auth`. Make sure the filename is written correctly.
    at t.assertConfig (/var/task/.next/server/chunks/283.js:6:110918)
    at _ (/var/task/.next/server/chunks/283.js:6:104132)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async a (/var/task/.next/server/chunks/283.js:30:19639)
    at async e.length.t (/var/task/.next/server/chunks/283.js:30:21055)
    at async /var/task/node_modules/@sentry/nextjs/cjs/common/wrapRouteHandlerWithSentry.js:48:32 {
  code: 'MISSING_NEXTAUTH_API_ROUTE_ERROR'
}

This mentions /pages/api/auth which of course doesn’t exist (this project uses app router, not pages). What’s going wrong? Anyone have any ideas? I’ve been stuck on this for a very long time now, and can’t seem to get it working.

I’ve just solved it :slight_smile: I’ll post my fix in case it helps someone else in the future.

Turned out I’d initially called my folder […nextAuth], and in a later commit fixed this by renaming the folder to […nextauth]. This works fine locally, but in git a case-change is apparently not committed, so in my github repo it was still […nextAuth].
git mv [...nextauth] temp
git commit -m "Name fix"
git push
git mv temp [...nextauth]
git commit -m "Name fix part 2"
git push

After Vercel had rebuilt and redeployed everything works now! :slight_smile: