Getting an error on signup when using identity-signup function

I use Netlify identity.
I created identity-signup function and return the following response from it:

const handler = async (event: Event, context: Context) => {
    return {
        statusCode: 200,
        body: { "user_metadata": { "roles": ["customer"] } },
        headers: {
            'content-type': 'text/html',
            'cache-control': 'no-cache'
        }
    };
}

module.exports = { handler }

When I do sign up and then confirm the email I’m getting this error:

I tried changing the function’s response to
{ "app_metadata": { "roles": ["customer"] } }

But still having the same error.

When I look at the backend - I see the user is created, but has no roles attached to it.

Website: https://develop--amspilot.netlify.app

When I remove the function identity-signup then the signup works without errors, but obviously I have to ability to set user metadata in this case.

I wonder if there is an example repo showcasing how identity-signup should work. The one that is actually using the latest identity service(I found the ones very old)

I made it work!

Thank you

Thank you for coming back and sharing your updates, I am glad you got everything working.

Happy building :rocket: