Skip to content

fix(cloudflare): globally polyfill env#3401

Merged
pi0 merged 2 commits intov2from
fix/cf-global-env
Jun 11, 2025
Merged

fix(cloudflare): globally polyfill env#3401
pi0 merged 2 commits intov2from
fix/cf-global-env

Conversation

@pi0
Copy link
Member

@pi0 pi0 commented Jun 11, 2025

should potentially fix #2054

For process.env support in cloudflare (without nodeCompat -- which is disabled by default and opt-in), we expose env via __env__ from the fetch handler, which works for any code running after the request.

Recently, cloudflare introduced { env } export from cloudflare:workers. With this, we can make the global polyfill work without nodeCompat flag (in v3 is probably not needed as we enable it by default)

@pi0 pi0 changed the base branch from v3 to v2 June 11, 2025 07:31
@pi0 pi0 changed the title fix/cf global env fix(cloudflare): globally polyfill env Jun 11, 2025
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jun 11, 2025

Deploying nitrojs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1c3fb8e
Status: ✅  Deploy successful!
Preview URL: https://b12dc983.nitrojs.pages.dev
Branch Preview URL: https://fix-cf-global-env.nitrojs.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant