Trouble with custom signup and automatic login flow in Next.js with Auth0

Hi everyone,

We’re working on a Next.js application using @auth0/nextjs-auth0 v3.5.0, and we’re running into some issues with our custom login/signup flow.

Here’s the setup:
• We’re using the custom login page template with some changes to match our UI requirements.
• We have a Post User Registration Action that performs some operations in our backend.
• In the HTML template, we’re already using webAuth.login and webAuth.signupAndLogin.

What we’re trying to do is customize the signup flow: instead of using signupAndLogin, we perform just the signup, and after a successful response, we wait 3 seconds (using setTimeout) to give the Action time to complete. Then, we attempt to trigger login automatically.

However, this flow is not working as expected. It behaves strangely: the user is signed up, the login seems to happen, but then they’re unexpectedly redirected back to the login page — as if the login didn’t persist or was ignored.

As shown in the attached screenshot, right after the /resume step, there’s a redirect to a strange URL, which appears to be the root of my Next.js app. Interestingly, when I log in directly with an existing user (without going through the signup flow), everything works perfectly, and the user is redirected to the correct callback URL (/api/auth/callback).

None of this behavior makes sense to us. We’d really appreciate any help to understand what’s going wrong and how we can properly implement this flow.

Thanks in advance!

It seems that I can’t attach a screenshot here:

An error occurred: Sorry, you can't embed media items in a post.