Can't add custom routes in wrangler.toml.
When I tried to add custom routes, I encountered this error. Does anyone know how to resolve it? Thanks!
14 Replies
its probably within a [[something]] block above it, try putting routes at the top level
when you do a [[something]] everything below it goes inside
you're lucky your extension caught that, its a nightmare to debug otherwise
error changed..
that's not what i meant
can you share the whole file?
Cloudflare Docs
Custom Domains | Cloudflare Workers docs
Custom Domains allow you to connect your Worker to a domain or subdomain, without having to make changes to your DNS settings or perform any certificate management. After you set up a Custom Domain for your Worker, Cloudflare will create DNS records and issue necessary certificates on your behalf. The created DNS records will point directly to y...
yeah
so you see where it has the sections like [vars] and such
you need to put it above all of those
the line underneath
compatibility_date = "2024-10-11"
is a good place to put itoops
thanks! will try
in this specific case you were accidentally defining "routes" under the section for a d1 database
actually, kv namespace, hard to read without syntax highlights
The deployment was successful, but the domain I added is not working… This doc doesn’t specify whether it should be placed under “Vars,” so maybe it should go somewhere else....
workers domain: -> works
https://workers.chenbin0802.workers.dev/
my routes settings domain: -> (This site can’t be reached)😟
http://api.dealsniffer.io/
no it shouldn't go under vars, it goes above vars
anything below is part of the block and its not a variable
routes is a top-level setting like main and name
Thanks again, I think I’m getting closer to the correct configuration… This time, the deployment did not create a worker.dev domain; instead, it directly displayed a custom domain and added a new configuration in the DNS settings for me.
But, still "this site can't be reached"...
its dns cache, you accessed it before it was live so the domain not resolving got cached
you can try on a different network, go through the steps of clearing browser/device/router dns cache, or just wait
This has really helped me out; thanks a ton!👍