External domains served by Worker
Hi!
I've built a SaaS with Workers as the backend.
Right now every user on my site gets a custom page like saas.com/username.
I'd like to add a feature where users can add their own domains to the platform and have their site served on that domain.
Let's say user owns mydomain.com. Is there a way to set DNS records on mydomain.com so that the domain points to the same Worker that is serving saas.com/username ?
13 Replies
You can add custom domains at Workers/Overview/xxx/Add Custom Domain in the CloudFlare console, but the domain DNS has to be hosted by CloudFlare (why wouldn't
So if an user has their own domain with like godaddy there is no way to add it as a custom domain?
Hmm.. the docs suggest this might be possible:
And for an active cloudflare zone i can do:
What you're looking for is Cloudflare for SaaS. https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/
That should work, but to be honest, anyone supporting GoDaddy get's my disrespect 😉
Sadly Apex proxying is an enterprise only feature
And without that it does not seem possible to route the root mycustomdomain.com to the worker
Or at least thats what i'm reading from the docs here:
@zegevlier are my assumptions correct?
That depends on the DNS provider of your clients. If they're on Cloudflare, it'll all work fine since CF does allow CNAME records at the root zone (on all plans). If they use something else, it depends on what that provider does
Yeah, most users are not tech savvy enough to use cloudflare and most other dont support this feature
@vassbence did you managed to find a solution for this?
I just user Vercel for this use case as they provide unlimited domains for the pro plan which is like 10 usd
for cloudflare i'd have to sub to the 1000+ usd enterprise plan to get the same stuff
my frontend is next.js so this works out
This works, however vercel will charge you for data transfer, I don't know your exact setup.
However in my case 10 usd would be way cheaper then egress fees on vercel.
I have managed to get it worked by the way ~
mind sharing your setup?
https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/start/advanced-settings/worker-as-origin/
I followed this exactly.
Workers as your fallback origin · Cloudflare for Platforms docs
Learn how to use a Worker as the fallback origin for your SaaS zone.
and so you end up with an IP address which users can point their domains to?