I'm using a CMS that uses Cloudfront to serve images. I want to bypass this CDN by downloading and optimizing the images at build time like Astro's Image component and next/image do.
From the CMS, I get an image URL. In Astro and Next.js, the respective image optimizing component takes the image from the URL and creates a local optimized version.
Now I'm using React Router 7, and it doesn't come with a built-in image component. What can I do achieve the same? The main reason I'm doing this is to avoid the high bandwidth costs from the CMS, so I'd rather just serve them right from my Cloudflare Worker instance.
Example:
<Image src={cms.image.url} />
Becomes
<img src="/assets/optimized_image.avif" />
at runtime.
Manually downloading the images in advance or using another provider to host the images is not an option.