White label my app/service workers.
Hello there !!
I am trying figure out if there a easy way to deploy clouldflare worker to mutiple prod env.. here are my use cases
Web app that is deployed as A.com and B.com, each having it's own env vars.. pretty much as two separate apps.
Create service X that i want to want to easy reuse for different products, again each deployment of a service has its own env vars..
THanks for reading and maybe answering!
5 Replies
I think what you are suggesting is a 'single tenant' approach where each domain (customer?) has their own deployment. This would allow for each deployment to have it's own env vars. In order to do this and make it automated, you would need a management system that dynamically creates multiple workers using Cloudflare API. Note that there is a 500 worker limit for the paid workers plans so you will eventually hit a limit. Not trivial IMO. I don't think there is any other way to do this .. can someone confirm?
There may be good reasons why it's not feasible (e.g. different code versions per deployment), but I would consider a 'multi tenant' approach if you can. This would mean one deployment. a.com and b.com just need to be a cname that points to your designated worker domain. The initial code could detect the incoming domain requested and retrieve the appropriate env data from a central data-source, rather than from the standard worker env.
Thanks @rdutton .. Single tenant is pretty much the prefered approach!!
I thought cloudflare might have an easy way of getting that done!!
I thought cloudflare might have an easy way of getting that done!!
I think this is what https://developers.cloudflare.com/cloudflare-for-platforms/ is intended to serve
Cloudflare Docs
Cloudflare for Platforms · Cloudflare for Platforms docs
Extend Cloudflare's security, reliability, and performance services to your customers with Cloudflare for Platforms. Together with Cloudflare for SaaS and Workers for Platforms, your customers can build custom logic to meet their needs right into your application.
I haven't tried it yet, but it is my plan to see if this fits the need
Thanks @verdverm.com will take a look