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
owopi8mo ago
this is using process.env.VAR
No description
owopi
owopi8mo ago
this is using import.meta.env.VAR
No description
owopi
owopi8mo ago
No description
owopi
owopi8mo 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 Garcia8mo ago
You have to use Astro.locals.runtime;
Beto Garcia
Beto Garcia8mo ago
Documentação do Astro
@astrojs/cloudflare
Learn how to use the @astrojs/cloudflare SSR adapter to deploy your Astro project.
owopi
owopi8mo 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
More Posts
Worker Unable to Connect Env VariablesI am following this tutorial https://developers.cloudflare.com/vectorize/get-started/intro/#2-createGetting "context is not defined" errorAttempting to use `context.env.VARIABLE` for a few environment variables I have set up, however I'm Reverse Proxy Worker forwarding requests to Zero Trust backend causing a 302 redirection loop.My reverse proxy worker seems to be dropping the CF-Auth tokens from Zero trust when forwarding withworkers.api.error.invalid_script_config error 10202Hi, I'm trying to PATCH script settings to add the D1 binding of a dynamically created D1 database (Cannot add custom domain after removing from one pages project, and attempting to add to anotherI was attempting to point our production name (www.rhone.com) from one pages project to another by dTrying to do a POST redirect in a WorkerHello, I am trying to recreate a POST redirect in a worker. So the user POST data to a worker and I File Size Limit QuestionSo I saw that the maximum file size for the cloudflare pages free plan is 25MB. I've been trying to multiple producersHello everyone. I am trying to build a worker which takes in requests via an API and the pushes to aCloudflare incident on October 30, 2023Hi folks — here's our postmortem: https://blog.cloudflare.com/cloudflare-incident-on-october-30-2023Can't seem to find Builds & deployments and in my Cloudflare Pages settingsHi, I can't seem to find Builds & Deployments in my settings as I'm trying to add a deploy hook.