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
owopi
owopiOP13mo ago
this is using process.env.VAR
No description
owopi
owopiOP13mo ago
this is using import.meta.env.VAR
No description
owopi
owopiOP13mo ago
No description
owopi
owopiOP13mo ago
this used to work before, but no longer does i am unsure whether this is a fault of astro or cf pages though
Beto Garcia
Beto Garcia13mo ago
You have to use Astro.locals.runtime;
Beto Garcia
Beto Garcia13mo ago
Documentação do Astro
@astrojs/cloudflare
Learn how to use the @astrojs/cloudflare SSR adapter to deploy your Astro project.
owopi
owopiOP13mo ago
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
Want results from more Discord servers?
Add your server