Cross-domain request to Worker

I an trying to make a cross-domain fetch from localhost to a Worker hosted in Cloudflare. The worker definitely works when run from its own domain and from withing the Cloudflare Editor. I have tried a number of different cors and no-cors approaches, but fetch always has ‘null’ as the body content. The requested file does actually contain ‘null’; however, when this is true, the job of the Worker is to actually return something else.

Are cross-domain fetches from localhost to a Cloudflare Worker possible? If so, what are the header or config tricks to make them work?

1 Like

Are worker routes set up for your zone?

If you mean the route tab form the Worker editor, yes: https://*.cloudworker.io/db.html, which is the “empty” file I mention.

DO I need to change it to https://cloudworker.io/db.html if I am just accessing the root domain?

I believe that is what is missing a route

https://cloudworker.io/db.html

This worked. Thanks.