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!
No description
14 Replies
Erisa
Erisa2mo ago
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
Briancb
BriancbOP2mo ago
error changed..
No description
Erisa
Erisa2mo ago
that's not what i meant can you share the whole file?
Briancb
BriancbOP2mo ago
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...
Erisa
Erisa2mo ago
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 it
Briancb
BriancbOP2mo ago
oops thanks! will try
Erisa
Erisa2mo ago
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
Briancb
BriancbOP2mo ago
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/
Erisa
Erisa2mo ago
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
Briancb
BriancbOP2mo ago
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"...
No description
Erisa
Erisa2mo ago
its dns cache, you accessed it before it was live so the domain not resolving got cached
No description
Briancb
BriancbOP2mo ago
Erisa
Erisa2mo ago
you can try on a different network, go through the steps of clearing browser/device/router dns cache, or just wait
Briancb
BriancbOP2mo ago
This has really helped me out; thanks a ton!👍
Want results from more Discord servers?
Add your server