Next.js Discord

Discord Forum

What is supposed to happen if you try to sign in but you haven't made an account?

Unanswered
Ojos Azules posted this in #help-forum
Open in Discord
Ojos AzulesOP
Our users get an error after clicking "continue with google" and get redirected to the sign-in page again with this error below instead of asking them to create an account.

1 Reply

Ojos AzulesOP
ok I figured it out.

I was doing:


afterAuth(...) {
    if (!auth.userId && !isPublic) {
      console.log("Redirecting to sign in...");
      const signInUrl = new URL("/sign-in", req.url);

      signInUrl.searchParams.set("redirect_url", req.url);

      return NextResponse.redirect(signInUrl);
    }


I changed the stuff inside the if block to:
return redirectToSignIn({ returnBackUrl: req.url });