Better AuthBA
Better Auth•11mo ago
janusanus

setRole doesn't work

I'm using NextJS@14.

Hello, I'm trying to give a user the admin role, but it's not working and I am not getting an error message/code.

here is my code (a server action):

export async function setAdmin(id: string) {
    const updatedUser = await authClient.admin.setRole(
        {
            userId: id,
            role: "admin",
        },
        { headers: headers() }
    )

    console.log("User is now an admin", updatedUser, id)
}


The response i get:

User is now an admin { data: null, error: { status: 0, statusText: '' } } ZFgfmRxHcP8Exszk07b9CZOsteXMiQ62


If you have an Idea of what went wrong please let me know.
Any help is appreciated 🙌
Was this page helpful?