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 ?
15 Replies
IDisposable
IDisposable2y ago
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 cloudflare
vassbence
vassbenceOP2y ago
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:
Add a Custom Domain
To add a Custom Domain, you must have:

- An active Cloudflare zone.
- A Worker to invoke.
Add a Custom Domain
To add a Custom Domain, you must have:

- An active Cloudflare zone.
- A Worker to invoke.
And for an active cloudflare zone i can do:
Partial (CNAME) setup: Keep your primary DNS provider and only use Cloudflare’s reverse proxy for individual subdomains.
Partial (CNAME) setup: Keep your primary DNS provider and only use Cloudflare’s reverse proxy for individual subdomains.
IDisposable
IDisposable2y ago
That should work, but to be honest, anyone supporting GoDaddy get's my disrespect 😉
vassbence
vassbenceOP2y ago
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:
In a normal Cloudflare for SaaS setup, your customers route traffic to your hostname by creating a CNAME record pointing to your CNAME target.

However, most DNS providers do not allow CNAME records at the zone’s root. This means that your customers have to use a subdomain as a vanity domain (shop.example.com) instead of their domain apex (example.com).
In a normal Cloudflare for SaaS setup, your customers route traffic to your hostname by creating a CNAME record pointing to your CNAME target.

However, most DNS providers do not allow CNAME records at the zone’s root. This means that your customers have to use a subdomain as a vanity domain (shop.example.com) instead of their domain apex (example.com).
@zegevlier are my assumptions correct?
zegevlier
zegevlier2y ago
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
vassbence
vassbenceOP2y ago
Yeah, most users are not tech savvy enough to use cloudflare and most other dont support this feature
Codename_404
Codename_40416mo ago
@vassbence did you managed to find a solution for this?
vassbence
vassbenceOP16mo ago
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
Codename_404
Codename_40416mo ago
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 ~
vassbence
vassbenceOP16mo ago
mind sharing your setup?
vassbence
vassbenceOP16mo ago
and so you end up with an IP address which users can point their domains to?
Jatto
Jatto2w ago
@Codename_404 I can't seem to finalize the customer's domain to trigger the worker. I end up getting a 522. Any tips?
Jatto
Jatto2w ago
No description
No description
No description
Want results from more Discord servers?
Add your server