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 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; I tried [vars], and [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!
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?