Can't access environment variables in Wrangler dev

I've added environment variables in my CF dashboard. When running wrangler dev I expect to be able to access these in a function (e.g. export async function onRequestGet(context) {console.log(context.env)}). However, the variable I've set in my CF dashboard is always undefined. There's some confusion around whether I need to define these locally (e.g. in a .env file). I've tried this, but this also does not work. I'd prefer to NOT have to define them locally (similiar to the Netlify dev UX, where ones defined in the panel are available locally). Any insight?
4 Replies
JustinNoel
JustinNoel12mo ago
For local development, you have to define them locally in a .dev.vars file.
jayMakes11
jayMakes1112mo ago
Thank you! That worked. I searched the docs far and wide and didn't find this.
bacon
bacon7mo ago
@jayMakes11 @JustinNoel im running into this as well and don't understand what I'm missing can you say more aobut the solution?
JustinNoel
JustinNoel7mo ago
Can you explain your exact problem?
Want results from more Discord servers?
Add your server
More Posts
Does not work correctly on domains with wwwHi, we have a domain example.com where the cloudflare pages works correctly, and the web is displayeDisable appname.pages.dev and *.appname.pages.devHello, I want to disable the pages subdomain for the website and allow only to be accessed from the CSP is blocking Cloudflare even though I rewrote the CSP headerI'm running a software called Mattermost, and whenever I proxy it through Cloudflare, I receive thisCloudflare Pages Action for GitHub fails deploymentFailed run: https://github.com/revanced/revanced-website/actions/runs/5329334447 Last working deployI don’t see any option to enable HTTP/3 PrioritiesAccording to this article, I try to find the option to enable this feature but i cannot see it. httpwhen i click "Manage API Tokens" in the workers dash it takes me to an upsell page for buying R2I'm just trying to generate an API token for deploying Workers Pages from CI. The link is correct, sRedundancy in Cloudflare Workers and Implementing a Backup ServerHey! I hope you all are doing well! I need a little bit of help or guidance regarding an issue that Is it still not possible to create durable objects inside a pages project?After the recent blog post about workers and pages moving together this would work soon See also htit definitely has the edit permissionit definitely has the edit permissionLoadbalancer Maintenance/Holding PageLooking for a way for the Cloudflare Loadbalancer to somehow display a maintenance page if all origi