Wrangler environment variables are undefined
I followed the Astro guide (https://developers.cloudflare.com/pages/framework-guides/deploy-an-astro-site/) and I tried setting an env var in wrangler.json and accessed it with Astro.locals.runtime.env.MY_VARIABLE and it works in dev but it is undefined in preview/build.
Steps to reproduce:
1. Create the project with
2. Uncomment the like in wrangler.json and add the comma above it.
3. Make the start of src/components/Welcome.astro the following:
Any help would be much appreciated. Thanks
Cloudflare Docs
Astro
Astro is an all-in-one web framework for building fast, content-focused websites. By default, Astro builds websites that have zero JavaScript runtime code.
0 Replies