admin plugin ban user - unauthorized

How do I ban a user in a server side route?
Thought thats the way how you perform actions on the server side

      await auth.api.banUser({
        body: {
          userId: input.id,
          banReason: 'Your account has been deleted and is no longer available.',
        },
      });


But this just throws an error when it's being executed:
[Error [APIError]: ] {
  status: 'UNAUTHORIZED',
  body: undefined,
  headers: {},
  statusCode: 401
}
Solution
provide headers, UNAUTHORIZED status is when you dont provide any authorization in your request
image.png
Was this page helpful?