Cross-domain request to Worker

#1

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?

0 Likes

#2

Are worker routes set up for your zone?

0 Likes

#3

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?

0 Likes

#4

I believe that is what is missing a route

https://cloudworker.io/db.html

0 Likes

#5

This worked. Thanks.

0 Likes