🌏 中文版
TL;DR
In the routes config, set pattern to just the hostname — no /* — and pair it with custom_domain: true.
Context
After deploying a blog to Cloudflare Workers, I wanted to bind quidproquo.cc to replace the default *.workers.dev URL.
The Problem
I added the following to wrangler.jsonc:
"routes": [
{ "pattern": "quidproquo.cc/*", "custom_domain": true }
]
Running wrangler deploy threw an error:
Invalid Routes:
quidproquo.cc/*:
Wildcard operators (*) are not allowed in Custom Domains
Paths are not allowed in Custom Domains
The Fix
For a custom domain, the pattern should be just the hostname — no paths or wildcards:
"routes": [
{ "pattern": "quidproquo.cc", "custom_domain": true },
{ "pattern": "www.quidproquo.cc", "custom_domain": true }
]
After making this change, you need to run astro build again — the Cloudflare adapter copies the config into dist/server/wrangler.json, so running wrangler deploy directly will use the stale file from the previous build.
Why This Happens
Custom domains and route patterns are two distinct mechanisms. A route pattern like example.com/* is for zone-based routing and performs path matching. A custom domain, on the other hand, points the entire hostname directly at a Worker — paths are neither needed nor permitted.
What I Learned
When using custom_domain: true, the pattern is just the hostname. Adding a path breaks it. And any time you change wrangler.jsonc, you need to rebuild before deploying.
References
Loading...