Strapi v4 Error Message does not work properly

System Information
  • Strapi Version: 4.1.7
  • Operating System: Mac OS Monterey
  • Database:
  • Node Version: v17.0.1
  • NPM Version: 8.1.0
  • Yarn Version:

Hi,

I use the correct strapi endpoint for registering user:

const strapiRes = await fetch(`${API_URL}/api/auth/local/register`, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
            },
            body: JSON.stringify({
                username,
                email,
                password,
            }),
        })

When I do testing and intentionally use a existing email it returns correct error message of “Email already taken”

When I do testing and intentionally use a existing username while having a unique email entered and matching password and confirm password it does not return “Username already taken” but returns “An error occurred during account creation” instead.

This is not ideal because it does not tell the user how to fix the problem but instead can imply to the user that it is the system that is broken…

Interestingly enough, when I leave the username field blank and have a unique email filled in and the matching password and confirm password, that is when it returns “Username already taken” instead of “Username is a required field”.

1 Like

I can confirm this - the same is happening with me.

Though I am using GraphQL mutation, and I am just getting a generic error response saying," Internal Server Error". - however, in the Strapi terminal logs, I can see the same behavior you described in the post.

Any news on this? I’m still getting the same.