David Henry
David Henry

Reputation: 3062

Server Error signing up user with OTP in supabase

I'm using Supabase for auth and facing a server error of;

Error: An unexpected response was received from the server.

Everything works after this error though, I have my auth/callback/route.js set up correctly, so when I get the email it goes to the right destination. But this error is a mystery?

Here is the error I'm getting in the logs;

⨯ [TypeError: Invalid URL] {
  code: 'ERR_INVALID_URL',
  input: '?message=Check email to continue the registration process',
  page: '/sign-up'
}

Here's my code;

export async function signUpWithOTPAction(formData) {
  const verifiedFormData = signUpWithOTPSchema.safeParse(formData);
  const email = verifiedFormData.data.email;

  const supabase = await createClient();
  const { error } = await supabase.auth.signInWithOtp({
    email,
    options: {
      emailRedirectTo: `${defaultURL}/welcome`,
    },
  });

  if (error) {
    console.log("ERROR:", error);
    console.log("ERROR MESSAGE:", error.message);
    redirect("/?message=Could not authenticate user");
  }

  return redirect("?message=Check email to continue the registration process");
}

It's also obviously redirecting to the "?message=Check..."

What am I doing wrong here?

Upvotes: 0

Views: 44

Answers (0)

Related Questions