Next.JS API returning errorType : "Runtime.UnhandledPromiseRejection"

Hello,

I have Next.JS application with next version 12.3.1, my issue is that I have this forgot password page (https://carlisle.staging.digit-sense.com/auth/forgot-password) that will hitting API once the form is submitted, but the API is returning 502 errorType: “Runtime.UnhandledPromiseRejection”, it’s pretty hard to me to troubleshoot because it’s working fine in my local. Could Netlify support help me to solve this issue?

I already added the netlify.toml too in the root directory of the project but it seems not really affecting the issue
image

Hi @randidev, kindly try the settings below to see if it works.

[build]
  command = "next build"
  publish = ".next"

[[plugins]]
  package = "@netlify/plugin-nextjs"

[functions]
  included_files = [".next/*.json"]

You can also try the suggestions in the Official Netlify’s GitHub issues page at [Bug]: Updating plugin to v4 causes 502 error on some routes · Issue #1103 · netlify/next-runtime · GitHub

If it does not work, if possible can you share the repository of your site for me to help with the debugging.

Thanks.

Hi @clarnx , seems that’s not affecting the issue either, I still getting the same errors. May I have your GitHub username so I can add you to my repo?

Thanks in advance

Hi @randidev my GitHub username is clarnx
However I recommend you post the repository here if it does not contain any private information so that other community members here can also help as well with the debugging.

Thanks so much for the help here, @clarnx !

Also wanted to mention to @randidev that in case their code uses NextAuth (sounds like it might based on the subject matter), that is known not to work well at the moment, cf [Bug]: NextAuth basic middleware causes 500 internal error on all page .json file requests · Issue #1679 · netlify/next-runtime · GitHub .

Hi @fool ,
Yes, I’m using NextAuth for my app, but it’s returning 502 not 500, is it still relevant?

Hi @clarnx ,

Here’s my GitHub repository GitHub - randidev/erp

Hi @randidev, I tested your site and I can confirm the 502 Error exits.

[next-auth][error][CLIENT_FETCH_ERROR]

When you check in the Chrome Dev Tools you see the error quoted above.
I agree with @fool’s response as NextAuth has deploy issues with Netlify and Next.js

However, kindly check the link below to resolve the error above and then redeploy again to see if it helps resolves the problem.

Hope this helps.
Thanks.