Back

Error Creating User: AppwriteException: Invalid 'url' param: URL host must be one of: localhost ...

  • 0
  • React Native
  • Auth
Musti
10 Jul, 2024, 18:33

I'm working on authenticating a user for my expo app.

While the error does imply the error was in creating the user, the user is indeed created as I can see in the console.  My code looks like this: 

TypeScript
 export const createUser = async (email, password) => {
    try {
        const newAccount = await account.create(ID.unique(), email, password);
        if (!newAccount) throw Error('Error creating user');
        // login the user
        await Login(email, password);
        // Send verification email
        console.log('login compl')
        const verify = await account.createVerification('bookquest://(auth)/verify');
        console.log(verify)


        return newAccount;
    } catch (error) {
        console.log(error);
        throw new Error(error);
    }
}

// signin
export const Login = async (email, password) => {
    try {
        const session = await account.createEmailPasswordSession(email, password);
        return session;
    } catch (error) {
        throw new Error(error)
    }
}```

The terminal  looks like this: 

 iOS Bundled 278ms node_modules/expo-router/entry.js (1 module) LOG login compl LOG [AppwriteException: Invalid url param: URL host must be one of: localhost, cloud.appwrite.io, appwrite.io]```

Would appreciate some guidance as I am stuck and really would like to move forward with my project

TL;DR
Error message indicates issue with 'url' parameter hosted on specified URLs like localhost, cloud.appwrite.io, appwrite.io. Check if the hostname in project platform list. User is created, so the issue is not there. Code snippet provided. Error occurs during verification step for user authentication in expo app. Solution: Verify if 'bookquest://(auth)/verify' in list, or modify code as needed.
Kenny
10 Jul, 2024, 18:38

I believe it has to do with your create verification step.

Kenny
10 Jul, 2024, 18:38

This is from the docs

Only URLs from hostnames in your project platform list are allowed.

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