Use D1 Binding at Pages Build Time

For Workers & Pages, what is the name of the domain?

whitehousewatcher.org

What is the issue or error you’re encountering

I want to use my D1 database bindings at build time to generate static pages for my Astro site. However, in my npm run build step, it seems the D1 DB binding is undefined.

Screenshot of the error

d1cf1.png

I do successfully see environment variable bindings, but it seems the D1 binding isn’t attaching to the build command.

It looks like you are unable to access production bindings during build unless you were to use the http APIs to connect directly to them, which isn’t really an option for most (all?) ORMs