Image Resize on Worker return 404

Hi, :grinning:
I am on business plan, and my Cloudflare domain is I am trying to run image resize on my worker, which custom domain is I met 404 response when I add query in the url.

  • 200
  • 404
  • 200

I found there’s a similar post but looks like not being solved.

This is my worker script.

export default {
  async fetch(request, env) {

    let url = new URL(request.url);

    const config = {
      width: url.searchParams.get("w"),
      height: url.searchParams.get("h"),
      quality: url.searchParams.get("q"),
      fit: url.searchParams.get("fit"),

    const configPath = Object.entries(config)
      .filter((entry) => Boolean(entry[1]))
      .map((entry) => `${entry[0]}=${entry[1]}`)

    const imageURL = configPath.length 
     ? `${configPath}/${url.pathname}`
     : `${url.pathname}`;

    return fetch(imageURL);

Thanks for any help!

The is an A record point to google cloud load balancer ip.
And the cloud load balancer route the traffic to google cloud stroage.

AFAIK, you cannot use the /cdn-cgi/image/<config>/<url> endpoint in Workers subrequests to resize images. You have to use the cf.image request properties instead.

const response = await fetch('', {
  cf: {
    image: {
      fit: 'scale-down',
      width: 800,
      height: 600

1 Like

Thanks, @albert , I’ve tried to use fetch with cf before and met 502.
I opened another topic here.