hey when using `fetch request ` is there
hey, when using
fetch(request)
, is there a way to modify the path when fetching the request from the origin? I want it to use the proxied DNS target but I want to alter the path...9 Replies
I've been creating the full fetch URL myself but I wondered if I could keep the target from the DNS record and just alter the path...
just feels weird pointing the proxied record to any random name since I will be overriding it so I figured maybe I can use the name that it points to so it has meaning...
request.url
is the requested URL though... not the origin URL? or does Cloudflare then do behind the scenes work to fetch from the origin?If you put a Worker on top of an origin, there is no difference between the URLs.
Fetching the same URL in a Worker falls through to the origin
thank you @kian helpful as always!
@kian just trying to test this locally by putting a random URL as the target (which should most definitely return a 404) and it keeps saying that the origin response is a
200
... odd π€ Using wrangler in dev mode.
@kian so odd.. I set the target address as www.google.com
. Surely fetch(request)
should return a 404
as our pages don't exist in www.google.com
yet the origin seems to return 200
π€
@kian ok I discovered what the issue was π€¦ββοΈ I had a lingering origin rule that was rewriting the destination... driving me mad!
however, it looks like I can't use this anyway because it connects to the destination (in my case storage.googleapis.com
) but the Host
header is the original URL, and it needs to be storage.googleapis.com
otherwise it doesn't work as it has no idea how to handle the URLJust fetch that URL instead
yeah, that's what I was doing originally.. so I guess I'll go back to making the "target" in the DNS name any random name since it's not going to be used...
You can use a custom domain rather than a route for your Worker
oh to avoid the proxied DNS record? yeah, that's an option