import.meta.env in cloudflare pages
Whenever I try to use
import.meta.env
I get undefined, but process.env
works. Is there a reason for this?
There's one post on the forum, but no one has answered yet.
https://community.cloudflare.com/t/access-environment-variables-in-pages-in-ssr/7254692 Replies
If you're using Astro and Pages then I think this is what you're looking for.
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.
Not sure how that works in Astro Islands, but we use cloudflare pages for our nitro api as well. I know there are some differences between pages functions and workers, and we might migrate directly to workers eventually, but the
import.meta
doesn't work there as well.