admin管理员组

文章数量:1335180

I deployed this on Cloudflare Worker and I have assigned domain proxy.mydomain.tld to the worker.
then I open on browser but I couldn't see the logo.png instead I see the error message says:

Too many redirects. /logo.png (repeating same url..) /logo.png

so I open original domain of worker (ends with workers.dev) and it is worked and show me the logo.png.

here is my worker code:

try {
  // fetch to my website.
  const imageResponse = await fetch("/logo.png", {
    method: 'GET',
    headers: {
      'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 (compatible; ImageProxy/1.0; +/proxy.html)'
    }
  });
  // return image
  return new Response(await imageResponse.blob(), {
    status: 200,
    headers: { 'Content-Type': imageResponse.headers.get('Content-Type') }
  });;
} catch (err) {  
  return new Response(err, {
    status: 500,
  });
}

proxy.mydomian.tld is proxied via Cloudflare, while others (e.g. *.mydomain.tld, mydomain.tld, www.mydomain.tld) is DNS-only.

P.S: mydomain.tld and *.mydomain.tld's A Record are points to my vps for frontend. The Frontend VPS only installed certbot + nginx + zerotier vpn and configured to all HTTP(S) requests sent to www.mydomain.tld will forwarded to my HomeServer's 80 port. My HomeServer only installed nginx + zerotier vpn and hosting my website. For HTTP=>HTTPS redirect and non-www to www redirect is done by Frontend Nginx. And I thought this creepy setup cause this error.

本文标签: javascriptMy Cloudflare Worker that proxy image is not working properlyStack Overflow