#Multiple workers in different subdomains of same domain

10 messages · Page 1 of 1 (latest)

honest mica
#

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!

winged briar
honest mica
#

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

winged briar
honest mica
#

{ "$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

honest mica
winged briar