NextAuth integration doesn't work properly and leads to 404 error page when try to log in

PLEASE help us help you by writing a good post!

  • we need to know your netlify site name. Example: gifted-antelope-58b104.netlify.app
  • DNS issues? Tell us the custom domain, and tell us the error message! We can’t help if we don’t know your domain.
  • Build problems? Link or paste the FULL build log & build settings screenshot

The better the post - the faster the answer.
site name: https://friendly-macaron-595ca5.netlify.app/

I tried to manually deploy a next js web app that I could deploy successfully.
But for the authentication, I’m using next-auth library.
This authentication process works fine in dev env.
I used next build && next export cmd to build prod build.
once manual deployment success I ensure to add
NEXTAUTH_URL and NEXTAUTH_SECRET in the build and deploy section of the netilify.
Then I navigate to the Deploys tab via navbar and click
click the publish link again (I hope it would redeploy the site with newly setup env variables)

I can see my login page but getting 404 page when I tried to log in
Below you can find the console error


I’m not sure what the cause of the issue
Please assist me with this
Thanks

Hey @shehan-dinuka,

From the logs, it seems like you’re making a call to /api which could be Next.js API routes. Those are not supported with using next export. You’d have to run next build using Netlify CLI locally.