Too many redirects when making fetch requests from a worker

When I make a fetch request from a CF Worker, I'm getting a "Too many redirects" error from the fetch. The redirect URLs aren't changing, each new location is the same URL as the previous. This only happens when making requests to the same domain that the worker lives on (different subdomain). When making a request manually from my device, there are no redirects. It happens with any URL on the same CF domain. For example, if my CF worker lives on worker.example.com. When I use fetch in the Worker to make a request to https://api.example.com/somepath, the Fetch errors out with an infinite redirect, where each redirect location is https://api.example.com/somepath. I can make manual requests to https://api.example.com/somepath from my device and do not see any redirects.
4 Replies
Chaika
Chaika5mo ago
Is the api subdomain proxied? What's your SSL/TLS -> Overview SSL Mode?
ScarabCoder
ScarabCoder5mo ago
The API subdomain is not proxied The mode is set to Flexible
Chaika
Chaika5mo ago
Change it to Full (Strict) Flexible is trying to connect to your origin over http, hence the endless redirect Worker Fetch Requests/Subrequests are fun because they go through the cdn kind of like if the api subdomain was proxied
ScarabCoder
ScarabCoder5mo ago
Okay, I was wondering if that was the case. We've had issues in the past with proxying a CNAME record causing an infinite redirect. That worked, thank you for the help and quick response!
Want results from more Discord servers?
Add your server
More Posts