🚀 Feature Request: Detect whether code is being run in Cloudflare Workers (or Node.js)
See original GitHub issueDescribe the solution
Add some kind of macro to detect whether the code, that is currently being run, is running in Cloudflare Workers.
For example with esbuild
:
return esbuild.build({
define: {
IS_CLOUDFLARE_WORKER: 'true'
}
})
I’ve been using this for my custom Cloudflare Worker bundling (see github.com/brillout/build-worker/tree/build-worker.mjs#L20-L22).
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Possible to get PoP running worker code?
Hi, I just started using workers a couple of days ago to do some load balancing and failover depending on region of the...
Read more >Develop, test, and deploy Cloudflare Workers with Denoflare
Denoflare is a small framework that lets you publish Cloudflare Workers written in Deno. Here's how to develop, test, and deploy with it....
Read more >[Feature Request] Using stripe-node outside of Node.js (e.g. ...
I'm trying to setup a Stripe service as a serverless function using the Cloudflare Workers platform. But the stripe-node package seems to ...
Read more >Running RedwoodJS on Cloudflare Workers
In general, I foresee it being frustrating if my local dev environment spins up the API in a Node runtime so it's not...
Read more >What Cloudflare is up to featuring Jon Kuperman (JS Party ...
Thanks to listener Matt Mannucci for requesting this episode! ... Node.js application that they have, stick it on Cloudflare Workers, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe the Navigator API is the preferred way to do this
I just tried this in a worker:
and in the browser, I see: