[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
What do your routes look like? Are you trying to add a route for your workers.dev or something?
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)
The default workers.dev one yea. You're using wrangler, right? What does your wrangler.toml look like, do you have a routes section?
this is my wrangler.toml
Usually you do routes like this:
or if you wanted a worker custom domain
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 ithttps://myworkername.dev/ should be the route name:
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
updated^
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 disabledgot it. I'll remove the route line and add the
workers_dev = true
You've already got that in your config but yea
@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 ?
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
(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