Open joebailey26 opened 7 months ago
Great work ! Would happily accept a PR to expose the internals so that's easier to implement this on your own.
However I think we should eventually make the API more flexible to enable the ability to augment the options. Maybe the options could accept a function that returns a custom AuthConfig, with the event as an argument.
Describe the feature
Cloudflare exposes bindings via the
event.context.cloudflare.env
.Aside:
event.context.cloudflare.env
is only available when making a request, not when directly invoking the server function code. See Issue 137I'm using the Drizzle Adapter, but this would be the same for the D1 adapter.
I need to access the event inside my auth options, so that I can pass the database through to the adapter, like so:
The current
NuxtAuthHandler()
doesn't pass event toAuthOptions
as it expects the options as a parameter instead. I can't predefine options as I need access to the event from the handler within theNuxtAuthHandler()
function.I'm not sure what the best solution would be to solve this, but I've re-written
auth/[...].ts
so that I can pass the event through to my options. It's a bit of a pain as the utils aren't exported directly by this package, so I just had to copy and paste them.Additional information