I’m experimenting with cloudflare workers. I believe have two options for our developers to test out worker code:
Use real cloudflare workers on custom domains. We’d add a new cloudflare domain for each developer, and have our development workflow/script just upload changes directly to cloudflare (via api). This isn’t crazy ideal because dev code is out in the wild. We could lock it down to just service requests from our devs, but I’d rather not deal with that security layer if I don’t have to.
Side note: I’m pretty sure I can only deploy one worker script per cloudflare domain, right?
A little more about our server environment:
- Cloudflare workers are segmented to the route:
- Our node/express.js app handles all of
- Each endpoint has it’s own file/module that exports a
routevar. I have a bootstrap/entrypoint .js file that compiles all the endpoints together (using webpack) into a single file for cloudflare.
For our node.js development environment, I have a separate bootstrap .js file that wires up all the endpoints/routes. This sort of works, however as mentioned above, node.js has breaking differences from cloudflare workers. As an example, the Fetch API doesn’t naturally exist in node.js. I can sort of load it into node.js w/ node-fetch, however there are differences between
node-fetch and the Fetch API on cloudflare workers.
Is there a better way to do this? Perhaps I could build an express middleware function to proxy
example.com/api/* requests to another local environment? However, I’m not even sure how I can mimic cloudflare worker environment locally. Cloudflare workers run on V8, correct?