Relative Content

Tag Archive for next-auth

Auth.js [formerly next-auth] working locally, but not working when deployed to Azure App Service HTTP ERROR 404

I have implemented next-auth v5 into my Next.js application and everything is working fine locally; however, after I deploy to my Azure App Service, it no longer works. After I select my Microsoft Entra ID account (formerly Azure Active Directory account), I get an error indicating HTTP ERROR 404 for my-application.azurewebsites.net/api/auth/callback/microsoft-entra-id?code=long-code. I have attached redacted screenshots of it working on localhost and not working when deployed to the Azure App Service.

How to fix Authentication error while using auth provider

GET /api/auth/callback/github?code=3cb20730ec64fc4b5835&state=knyQ1F8LrcMMja0HsYJ3DAKYuO-gFHsUdqiMOXUH8CI 302 in 2039ms
GET /api/auth/error?error=User%20validation%20failed%3A%20verifyCodeExpiry%3A%20Verify%20Code%20Expiry%20is%20required%2C%20verifyCode%3A%20Verify%20Code%20is%20required%2C%20password%3A%20Password%20is%20required 200 in 45ms

Error: `headers` was called outside a request scope

I have just installed Authjs v5 on my nextjs14 project; the setup is as the documentation says and it’s in bare-bones condition I haven’t added any thing to the config files.
the proble is when I try to signIn, I get this error saying: Error: headers was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context.
how to solve this problem? I checked the documentation but couldn’t find anything helpful.