Hono on Cloudflare Workers with Better Auth always returning 401 Unauthorized
Using the better auth handler in the restricted endpoints like list sessions. It always returns unauthorized even after sign in with email.
I'm using Scalar docs to test the api. The cookie is being set I've checked by logging it. But still it's returning unauthorized.
Solution:Jump to solution
Fixed it by transforming the headers when passing to the routes
```
export const getHeaders = (headers: Headers) => {
const newHeaders = Object.fromEntries(headers as any)
const headerObject: Record<string, any> = {}...
2 Replies
when using directly by sending the headers with also is not returning the session
It seems it has something to do with cloudflare workers + headers issue.
Tried same code on node it seemed to work perfectly
Solution
Fixed it by transforming the headers when passing to the routes