Back

general_bad_request when creating user's account

  • 0
  • Auth
  • Cloud
Dave
26 Apr, 2024, 06:18

I came back to a project I was working on last year and now signing up with email does not work. Signing up with google oauth and login works.

This is the error response i get in network tab

TypeScript
{
    "message": "There was an error processing your request. Please check the inputs and try again.",
    "code": 400,
    "type": "general_bad_request",
    "version": "0.12.174"
}

This is my config

TypeScript
const client = new Client();
client
  .setEndpoint("https://cloud.appwrite.io/v1")
  .setProject(import.meta.env.VITE_APPWRITE_PROJECT_ID);

export const authAccount = new Account(client);
export const uniqueId = ID.unique();
export default client;

This is my signup function

TypeScript
export async function createUserAccount(
  email: string,
  password: string,
  name: string
) {
  try {
    await authAccount.create(uniqueId, email, password, name);
  } catch (error: any) {
    throw new Error(error);
  }
}

This is my submit handler function for the sign up

TypeScript
const signupSubmit = async (e: FormEvent<HTMLFormElement>) => {
    e.preventDefault();
    const { formData, isFormValid } = getValidFormData(e);
    const [nameField, emailField, passwordField, confirmPasswordField] =
      formData;
    const doesPasswordMatch = passwordField[1] === confirmPasswordField[1];
    
    console.log({ formData });
    try {
      if (isFormValid && doesPasswordMatch) {
        setIsLoading(true);
        const account = await createUserAccount(
          emailField[1] as string,
          passwordField[1] as string,
          nameField[1] as string
        );
        const userAccount = await getUserAccount();
      } else {
        toastError(
          "Cannot submit the form. Please check the highlighted fields for errors and try again."
        );
      }
    } catch (error: any) {
      toastError(error.message);
    } finally {
      setIsLoading(false);
    }
  };

I always get the error regardless of what inputsit receive and I don't even know what is wrong.

TL;DR
Issue: Users encountering a 'general_bad_request' error when trying to create an account via email in their appwrite package version 11.0.0 setup. Google OAuth and login work fine. Solution: Ensure the email, password, and name inputs are correct in the signup function. Consider checking the configuration settings and verifying if the provided data matches the expected format.
Dave
26 Apr, 2024, 06:21

I am making use of v11.0.0 of the appwrite package

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more