wojtodzio
CDCloudflare Developers
•Created by wojtodzio on 4/18/2025 in #general-help
Snippet for images optimization 404 when fetching correct URL
Hello,
I'm trying to use a simple snippet to route our images through the image‑optimization service with the correct rules for each platform.
This is my current snippet:
When used on the page, this snippet always returns 404.
If I uncomment
return new Response(
old: ${request.url}, new: ${url});
I get the expected rewritten URL, and opening that URL directly loads the optimized image.
When testing the snippet in DevTools, it randomly either fails with 404 or successfully fetches the image.
Could you help me understand why this happens?
Thanks!1 replies