Wildcard DNS with workers on a custom domain
I found a bunch of discussions, but still confused. I have a worker with a custom domain and a route defined:
And I have the DNS set for
AAAA * 100:: Proxied
Any request to anything.example.com
now get routed to the worker and it responds. So that works. I am trying to make my app route to different handlers depending on the subdomain (my SaaS has subdomain per user, and the app is written in Hono).
My idea was to check the Host
of the request and make routing based on that. But the Host
is always just example.com
, without the subdomain, and my in-app routing fails. What am I missing?
Developing locally it's a similar story: request to bla.localhost
has a Host
value of localhost
, not bla.localhost
. Running wrangler with --host
argument just changes the host, but never fixes the missing subdomain.6 Replies
(I also found info that custom domains don't support wildcard DNS, but I don't understand what it means... I have a custom domain and requests are routed to the worker. Is this "host" obfuscation precisely what that "no support" means?)
What about based on the URL?
Same,
req.url
does not contain the actual request url. Here I am returning req.url
:my
wrangler.toml
has route = { pattern = "*minifeed.local/*", zone_name = "minifeed.local" }
When deployed too?
Huh, sorry! Deployed works fine! Thanks!