getSession causing error: "Cannot read properties of undefined (reading 'validate')"

Hey, I'm trying to build my auth on my hono backend but I'm getting an error in my middleware when getSession() is called.
I was able to debug it and found out that when calling the getSession() function some kind of TypeError happens in the context (see screenshot).

Just for clarification:
I needed to initialize my better-auth instance via a function so I could pass the Cloudflare workers env bindings into my better-auth instance, as with CF workers it's not possible to access the process envs.

Does anyone have any idea what is causing this error?
image.png
Was this page helpful?