Skip to content

Odd path generation for the Cloudflare provider. #183

@Nicolas-Yakitori

Description

@Nicolas-Yakitori

const url = toUrl(options?.domain ? `https://${options.domain}` : "/");

As seen here, in the cloudflare.ts file, the generated path ends up lacking the domain in front of the /cdn-cgi/image/ path because there's only one parameter passed to the toUrl() function. So we end up with urls that look like "/cdn-cgi/images/(modifiers)/https://(url-with-domain)" instead of the expected(?) "https://(domain)/cdn-cgi/images/(modifiers)/(filename)

Default url generation, with a custom domain:
/cdn-cgi/image/width=2560,height=1440,f=auto,fit=cover/https://images.yakitori.ca/tuyaux-rapproches-blanc-rouille-3626x5439.jpg

What it should actually look like:
https://images.yakitori.ca/cdn-cgi/image/width=1800,quality=75,format=auto/plumbing-professional-doing-his-job-6000x4000.jpg
and this also works:
https://images.yakitori.ca/cdn-cgi/image/width=2560,height=1440,f=auto,fit=cover/https://images.yakitori.ca/tuyaux-rapproches-blanc-rouille-3626x5439.jpg

I managed to make it work by changing the toUrl to actually have 2 parts

const url = toUrl(`/cdn-cgi/image/${modifiers}/${stripLeadingSlash(src.toString())}`, options?.domain ? `https://${options.domain}` : "/");
 // url.pathname = `/cdn-cgi/image/${modifiers}/${stripLeadingSlash(src.toString())}`;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions