I'm trying to create a user with supabase.auth.admin.createUser() method in my Next.js project, but it fails with error

{
   message: "Database error creating new user"
   name: "AuthApiError",
   status: 500,
}

My code is:

const { data, error } = await supabaseAdmin.auth.admin.createUser({
        email: email,
        password: password,
        user_metadata: {
          nickname: nickname,
          introduce: introduce,
        },
      });

I've checked that email, password, nickname, introduce variables have correct values and types. I've also checked I'm using correct supabase instance with correct supabaseUrl and supabaseServiceRoleKey.

I'm wondering if I can get more specific error message instead of "Database error creating new user", or I want to know how to solve this problem.

1

There are 1 best solutions below

1
On

Had a similar issue and response from the server trying to do this using the python library as well. What fixed it for me was removing a trigger and function that ran on user creation that was having an issue. Luckily for me it was unneeded but I would check your triggers and functions for the auth schema and see if there's anything there causing the issue.