get env bindings from better auth email function context.

So inside of sendResetPassword I need to get my hono context to send emails, since my resend api key is in cloudflare workers and I am using JStack, how can I achieve this?
8 Replies
Slip
Slip2w ago
I had a similar problem with my db keys being in my azure vault, since better-auth expects credentials at module load time it can cause issues. I created a factory pattern around the better auth route provider on the server side, and passed the promise into the api routes, so at server start it first grabs keys in the promise before returning the server object Note the CLI will not work with this configuration, but at least the server runs
mov ecx, 420
mov ecx, 420OP2w ago
:PES2_HmmmmRobber: man I am dumb. I already pass the env field to get the db url when I create the auth instance, I can just reuse that :PES_Facepalm: I just realized it right after I sent the message. :aPES_LulLaugh:
mov ecx, 420
mov ecx, 420OP2w ago
this is my setup rn, when I use the middleware, I just create the auth context in backend and pass all env vars
No description
Slip
Slip2w ago
I probably should just load my keys into the env of the container instead of grabbing them at runtime Lol but I wanted to be able to point it elsewhere without changing the container
mov ecx, 420
mov ecx, 420OP2w ago
No description
mov ecx, 420
mov ecx, 420OP2w ago
and you can call it like this
Slip
Slip2w ago
azure also makes it literally so easy to inject my k8 container with envs from vault so I really dont know why I am overcomplicating this. Chat turned out to be enlightening lol
mov ecx, 420
mov ecx, 420OP2w ago
No worries, glad we could help each other

Did you find this page helpful?