Accessing assets from pages functions
Hey folks, I'm building an app on Pages using the CloudFlare Astro adapter. I'm trying to access some of my static assets in a function, but
Astro.locals.runtime.env.ASSETS
seems to be undefined
, both in directory or advanced mode. Does anyone know if there's any extra bits of config I need to do or?7 Replies
Just to confirm, are you using
astro dev
, or wrangler pages dev
?astro dev
with the miniflare runtime
For what it's worth I realized I can just fetch to my static files too ...astro dev
doesn't use Miniflare/Wrangler, unless you are doing something really cursed, so it won't have access to bindings
You would need to build your project, then run wrangler pages dev
This makes use of Miniflare under the hood no?
https://docs.astro.build/en/guides/integrations-guide/cloudflare/#cloudflare-runtime
Docs
@astrojs/cloudflare
Learn how to use the @astrojs/cloudflare SSR adapter to deploy your Astro project.
When I tried to figure out how it was implemented I was running into miniflare stuff
You need to use
wrangler
for Miniflare support: https://docs.astro.build/en/guides/integrations-guide/cloudflare/#preview-with-wranglerDocs
@astrojs/cloudflare
Learn how to use the @astrojs/cloudflare SSR adapter to deploy your Astro project.
Thanks for the help!