[NextJS] LoginHandlerError: Login handler failed. CAUSE: Discovery requests failing for {domain}, expected 200 OK, got: 404 Not Found

Hello,

I’m working to add Auth0 login to my NextJS application and I’m really struggling to get through the quickstart. To be specific, this one: Auth0 Next.js SDK Quickstarts: Login

I’ve cloned the auth0-nextjs-samples, carefully copied things from my settings, and the app does in fact start. It correctly detects my .env.local, though for some reason it rolls over to port 3002 as it thinks 3000 and 3001 are both in use. The login button does appear, but it gives the error when I click it.
The error I’m getting is:
LoginHandlerError: Login handler failed. CAUSE: Discovery requests failing for https://[my domain from the application in Auth0], expected 200 OK, got: 404 Not Found
with code: ERR_LOGIN_HANDLER_FAILURE

I’m using Ubuntu as my OS, and netstat has not helped me find what was on those ports, though I don’t think that should matter.

I am unsure how to proceed. I found one website that claimed adding an ipv4 force to next.config.js would help. It didn’t, but I have that in there now:
const dns = require(“dns”);

dns.setDefaultResultOrder(“ipv4first”);

From the same machine https://[domain] returns ping, responds to nslookup just fine, and when I use wget it pulls an index.html page just fine after a 302 redirect. So I don’t think it’s my network topology or other network config.

However, I have really done almost nothing to configure this app besides add the bits int he quickstart. I added and double checked several times that I have the proper callback url with the port we end up on (3002), On here I’ve found a few other threads that have reported this error; one was a docker problem (I’m not in any containers), and the other had people asking which quickstart - hence I added the link to what I’m following.

Can anybody help me get this working?

I’ll reply in case anyone else finds it. It was indeed a bad environment variable in my .env.local as others have run into. In my case, the .us. piece of my domain was missing somehow.

Once I got the correct value in, I was able to log in.

Hi @hearhere

I’m glad you figured it out. Thank you for sharing your solution with the community!

Thanks
Dawid

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.