Accessing D1 outside of a request in an Astro app

I'm using astro-auth [1] in an on-demand rendered app, using adapter-cloudflare [2] to deploy to Cloudflare workers.

My auth.config.ts file exists outside of a request, so I can't access my D1 database (context.locals.runtime.env.DB)

Is it possible to access the Cloudflare runtime outside of a request? If not, any tips on how to initialize astro-auth in middleware?

[1] https://github.com/nowaythatworked/auth-astro
[2] https://docs.astro.build/en/guides/integrations-guide/cloudflare/
GitHub
Community maintained Astro integration of @auth/core - nowaythatworked/auth-astro
Docs
Learn how to use the @astrojs/cloudflare SSR adapter to deploy your Astro project.
Was this page helpful?