Attaching custom hostname to worker

Is it possible to use the custom domain on a worker with a custom hostname I have set up. ie the domain I want to attach doesn't belong to the zone I have?
9 Replies
zegevlier
zegevlierβ€’12mo ago
No, you can only run workers on zones on your own account
Erisa
Erisaβ€’12mo ago
Fun sidenote though: You can with Pages Functions, as long as its a subdomain (i.e. not the apex example.com) and added as a custom domain to the project πŸ˜› Also Just realised You can do this with Workers if you add Cloudflare for SaaS Add the domain as a Custom Hostname in SaaS, then run the worker on a route including that domain
akandea
akandeaβ€’12mo ago
I have successfully done this by putting a route on worker - however due to the limitations of routes I would like to be able to do this without routes, ie something similar to custom domains. Custom hostnames doesn't seem to be the issue here, its pointing that hostname at a worker that seems to be lacking flexibility
Erisa
Erisaβ€’12mo ago
Its not possible sorry, workers custom domains won't work with saas custom hostnames, you have to use routes currently. It is possible to set a route to */* and then add exclusions for your zone hostnames instead of inclusions, but its still not as neat as the custom domain experience
akandea
akandeaβ€’12mo ago
Do you know if theres any way to deploy a worker to multiple domains? Is there any scope for cloudflare to allow custom hostnames on workers? Seems like a valid user journey as you have to prove ownership of domain when you do custom hostnames, so if you've proved you own it I think you should be able to attach a worker to it Say I have control of 4 domains and I want to deploy a worker to any one of these domains - is there anything I can do architecturally to allow this
Erisa
Erisaβ€’12mo ago
You can have multiple routes
akandea
akandeaβ€’12mo ago
The reason why I can't use routes is because I can't have these workers service bound, but I worker to worker calls are blocked when on routes - they aren't blocked on custom domains however
Erisa
Erisaβ€’12mo ago
For worker to worker communication its recommended to use service bindings, do you know if that would work?
akandea
akandeaβ€’12mo ago
Sorry if i didn't make this clear but I can't bind in this case due to them being separate services. We do make use of bindings but in the case where you're hosting a worker behind a domain, we don't want all other services to know that it is being hosted on a worker in order to make a call to it.
Want results from more Discord servers?
Add your server
More Posts