Admin Plugin: API Error Unauthorized

When calling auth.api.listUsers on the server. I'm getting an API error:
Failed to fetch users: [Error [BetterCallAPIError]: API Error: UNAUTHORIZED ] {
  status: 'UNAUTHORIZED',
  headers: Headers {},
  body: [Object]
}
 GET /admin 200 in 621ms
 GET /admin 404 in 700ms

oddly enough if i just fetch the api route directly:
await betterFetch("/api/auth/admin/list-users")

This works just fine. Granted I'm populating the Cookies on the headers explicitly. But to the best of my knowledge that isn't the issue the cookies seem to be getting set properly in either case, because I'm able to make every other type of request. Just not sure if its my config or something else.

Here's a link to the branch on my repo if anyone wants to check this out for me: https://github.com/innovations-dev/boiler15/blob/wip-admin/lib/auth.ts

Happy to answer any additional questions or provide other context if needed. Thanks in advance.
GitHub
Contribute to innovations-dev/boiler15 development by creating an account on GitHub.
Was this page helpful?