© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developers•8mo ago
groenroos

Environment variables not accessible in Pages Function when deployed with wrangler

We're moving from the Cloudflare Pages GitHub integration to building on GHA and deploying via wrangler, but in our testing, in the Preview link generated by the wrangler deployment, the Pages Function no longer has access to an
env
env
variable that continues to work just fine via the GitHub integration:

const handleRequest = async ({ next, request, env }) => {
    const variable = env.VARIABLE; // works with GH integration, undefined via wrangler
    /* ... */
};
const handleRequest = async ({ next, request, env }) => {
    const variable = env.VARIABLE; // works with GH integration, undefined via wrangler
    /* ... */
};


We downloaded the config via wrangler, and the variable is defined in
wrangler.toml
wrangler.toml
; I tried
[vars]
[vars]
, and
[env.preview.vars]
[env.preview.vars]
with no result. The var continues to be defined in the CFP UI (and in GitHub repo vars, too). It's also visible and correct under "Build settings" when viewing the resulting build in the CFP UI.

What should I do to make this env variable available in wrangler deployments? Thank you!
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Pages Function seemingly not deployed to base environment
Cloudflare DevelopersCDCloudflare Developers / pages-help
2y ago
Wrangler environment variables are undefined
Cloudflare DevelopersCDCloudflare Developers / pages-help
9mo ago
Cookie not set in pages deployed, but working with local wrangler
Cloudflare DevelopersCDCloudflare Developers / pages-help
9mo ago
How to set environment variables in `wrangler pages dev` for Nuxt + Cloudflare Pages project?
Cloudflare DevelopersCDCloudflare Developers / pages-help
13mo ago