# NextAuth error on production

**URL:** https://forum.codewithmosh.com/t/nextauth-error-on-production/24616
**Category:** Next.js
**Created:** [January 16, 2024, 1:24pm UTC](https://forum.codewithmosh.com/t/nextauth-error-on-production/24616 "2024-01-16T13:24:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![petervel](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/petervel/32/5094_2.png) [@petervel](https://forum.codewithmosh.com/u/petervel)
#### Post date: [January 16, 2024, 1:24pm UTC](https://forum.codewithmosh.com/t/nextauth-error-on-production/24616/1 "2024-01-16T13:24:53Z")

</div>

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:

> **[Google Cloud Platform](https://accounts.google.com/v3/signin/identifier?continue=https%3A%2F%2Fconsole.cloud.google.com%2Fapis%2Fcredentials&followup=https%3A%2F%2Fconsole.cloud.google.com%2Fapis%2Fcredentials&ifkv=ASKXGp2O9XtO_oHWftuif9cDC6IHXzxdnK2QoxjHDuvOFQ0OcXLYLbswYmbMkr18NiLlzr0QwEaQ&osid=1&passive=1209600&service=cloudconsole&flowName=GlifWebSignIn&flowEntry=ServiceLogin&dsh=S202256703%3A1705411200101998&theme=glif)**
>
> Google Cloud Platform lets you build, deploy, and scale applications, websites, and services on the same infrastructure as 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](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:

```auto
[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.

---

<div class="post-metadata">

### Author: ![petervel](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/petervel/32/5094_2.png) [@petervel](https://forum.codewithmosh.com/u/petervel)
#### Post date: [January 17, 2024, 10:25am UTC](https://forum.codewithmosh.com/t/nextauth-error-on-production/24616/2 "2024-01-17T10:25:12Z")

</div>

I’ve just solved it 🙂 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! 🙂

---

<div class="post-metadata">

### Author: ![warden](https://avatars.discourse-cdn.com/v4/letter/w/13edae/32.png) [@warden](https://forum.codewithmosh.com/u/warden)
#### Post date: [June 8, 2024, 8:40am UTC](https://forum.codewithmosh.com/t/nextauth-error-on-production/24616/3 "2024-06-08T08:40:36Z")

</div>

That amazing!  
I face the same problem too and fixed it by your method.

Thanks for your sharing! You make my day!!
