[ERROR] A request to the Cloudflare API failed... workers.api.error.route_not_allowed_on_subdomain

Any thoughts on how to debug this? I did some googling and came across this thread: https://community.cloudflare.com/t/workers-api-error-script-not-found-error-in-wrangler-publish/243644/4, but still haven't been able to fix it. Is there a way to double check if domain stuff are correctly configured with my worker or something? Thank you!
14 Replies
Chaika
Chaika13mo ago
What do your routes look like? Are you trying to add a route for your workers.dev or something?
John
JohnOP13mo ago
https://myworkername.dev/ that is my route (I changed the route name on Discord since it had my actual name in there lol) and I believe already added the route (automatically) no? (It's te one above)
Chaika
Chaika13mo ago
The default workers.dev one yea. You're using wrangler, right? What does your wrangler.toml look like, do you have a routes section?
John
JohnOP13mo ago
name = "cloudflare-org-dashboard-project-worker"
type = "webpack"

account_id = "eef6da33f8432f248ce8027d15cf035f"
workers_dev = true
route = "https://myworkername.dev/"
zone_id = ""
compatibility_date = "2023-11-21
name = "cloudflare-org-dashboard-project-worker"
type = "webpack"

account_id = "eef6da33f8432f248ce8027d15cf035f"
workers_dev = true
route = "https://myworkername.dev/"
zone_id = ""
compatibility_date = "2023-11-21
this is my wrangler.toml
Chaika
Chaika13mo ago
Usually you do routes like this:
routes = [
{ pattern = "subdomain.example.com/*", zone_id = "<YOUR_ZONE_ID>" }
]
routes = [
{ pattern = "subdomain.example.com/*", zone_id = "<YOUR_ZONE_ID>" }
]
or if you wanted a worker custom domain
routes = [
{ pattern = "shop.example.com", custom_domain = true }
]
routes = [
{ pattern = "shop.example.com", custom_domain = true }
]
I don't think zone_id like that is valid. Also, what is https://myworkername.dev/? Is it a domain you own, added in Cloudflare? If it's the default workers.dev, you just need workers_dev = true, don't need another route line for it
John
JohnOP13mo ago
https://myworkername.dev/ should be the route name:
Chaika
Chaika13mo ago
hm? If it helps, the exact cause of that error seems to just be when you try to add a route or custom domain on the workers.dev or a zone/domain you don't own
John
JohnOP13mo ago
No description
John
JohnOP13mo ago
updated^
Chaika
Chaika13mo ago
You don't need to add a route line for that default route in your wrangler.toml You just need workers_dev = true that what controls that being enabled or disabled
John
JohnOP13mo ago
got it. I'll remove the route line and add the workers_dev = true
Chaika
Chaika13mo ago
You've already got that in your config but yea
John
JohnOP13mo ago
@Chaika somewhat of a related question: I have a somewhat large csv file that I'm returning as a JSON when I call an endpoint. Is there a way to incorporate my .csv file into this project? Or do I have directly assign my csv file contents to a javascript const var ?
Chaika
Chaika13mo ago
Wrangler uses EsBuild under the hood to bundle your Worker. You can customize the loader to make it bundle/load other file types; https://developers.cloudflare.com/workers/wrangler/bundling/ https://developers.cloudflare.com/workers/wrangler/configuration/#bundling ex, add something like this to your wrangler.toml
rules = [
{ type = "Data", globs = ["**/*.csv"], fallthrough = true }
]
rules = [
{ type = "Data", globs = ["**/*.csv"], fallthrough = true }
]
(might be able to use Text instead of Data, would change the way its embedded, not sure on the specifics of that though) then you can just import and use
import data from "./test.csv";
...
return new Response(data);
import data from "./test.csv";
...
return new Response(data);
Want results from more Discord servers?
Add your server