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.