Multiple workers in different subdomains of same domain

Hi! I have 2 workers, worker1 and worker2 both created with CLI, one is a Hello World with Worker only and one is a Hello World with Worker + Assets. I wanted to set up custom domain for both (eg. worker1.mydomain.com and worker2.mydomain.com ) note that the mydomain.com in my example is also managed through Cloudflare under the same account The first worker I set up with a custom domain through settings works, the second one never seems to work. Note that both do work correctly if called from the default url workername.myaccountname.workers.dev Is this possible or am I missing something? Thank you!
5 Replies
1984 Ford Laser
1984 Ford Laser•3w ago
Have you set the routes in your wrangler config? https://developers.cloudflare.com/workers/wrangler/configuration/#routes
PizzaMarinara
PizzaMarinaraOP•3w ago
Hm no, I was missing that probably! What makes me wonder is that the first worker with the subdomain didn't need the wrangler configured like that, it just worked
1984 Ford Laser
1984 Ford Laser•3w ago
Are you sure you didn't add it to that one config? Weird otherwise
PizzaMarinara
PizzaMarinaraOP•3w ago
{ "$schema": "node_modules/wrangler/config-schema.json", "name": "worker-name", "main": "src/index.js", "compatibility_date": "2025-03-20", "observability": { "enabled": true } } this is the wrangler.jsonc of the worker that functions correctly the only difference is that the one working is the "Worker only" kind of setup, just plain simple .js function with no assets nor .html files dunno if it's relevant but it's a simple redirecting page with a given parameter. example: worker1.mydomain.com?video=cats will return a 302 redirect to a cat video on youtube anyway, this worked! Thank you for pointing it out, I totally missed that the config was needed also in the wrangler.jsonc file and not just in the Settings tab of the worker page. I think this can be marked as solved 🙂
1984 Ford Laser
1984 Ford Laser•3w ago
You should use only the wrangler config, or the Settings page. If you update the settings page, then push new wrangler config, the seetings page is overwritten The settings page in the dash is just a UI for wrangler basically

Did you find this page helpful?