unable to use envrionment variables using Astro JS
hello!
I am trying to use environment variables in my static Astro JS site, but when using process.env.VAR or import.meta.env.VAR (like the Astro docs suggest), I get build errors for both.
Whereas with netlify and vercel, both work and give me successful deploys
I have added the same env vars in both, and my cf pages builds suceeded last week but the same code no longer works.
Please let me know if more details are needed.
7 Replies
this is using process.env.VAR
this is using import.meta.env.VAR
this used to work before, but no longer does
i am unsure whether this is a fault of astro or cf pages though
You have to use Astro.locals.runtime;
Documentação do Astro
@astrojs/cloudflare
Learn how to use the @astrojs/cloudflare SSR adapter to deploy your Astro project.
ill try that once cf pages comes back, ty
well the thing is
im not using SSR
and i need to access env vars in a .ts file