Admin Plugin: API Error Unauthorized
When calling auth.api.listUsers on the server. I'm getting an API error:
oddly enough if i just fetch the api route directly:
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
boiler15/lib/auth.ts at wip-admin · innovations-dev/boiler15
Contribute to innovations-dev/boiler15 development by creating an account on GitHub.
4 Replies
are you passing
headers
I tried to add cookies bit the header object for listUsers doesn't take a Cookie or cookie property -- i tried both.
you need to pass the whole header object not cookies
That makes more sense let me try i'll get back to you. Thank you for clarifying that
That did the trick!
You're a life saver! TYSM