I'm fairly new to the Cloudflare ecosystem, I wanted to create a small OG renderrer for our organization's documentation page since it's also being hosted on CF, but I can't get "local" (to the project) images to work at all.
I'm building on top of the official Vite plugin guide, I have just one entry file that's returning the ImageResponse, and a pre-made background image in a public directory. It shows up just fine during local development. But when I deploy it to CF, I only get the template content with no background image using the following setup:
// worker entry file generating the image URL
const baseUrl = new URL(request.url).origin;
const bgImageUrl = `${baseUrl}/og-bg.png`;
All I get in CF is an error message reading
Can't load image <worker-url>/og-bg.png: Unsupported image type: unknown
when I check the logs.
I've tried using the URL for a backgroundImage style and a separate img tag, and a whole bunch of other more random attempts out of slight desperation, but nothing got me closer to getting it working. I've checked that the background image itself is available in the path specified, but I can't seem to get it working in the image generation.
But just giving it any regular external image URL in place of bgImageUrl works without issue
I'm fairly new to the Cloudflare ecosystem, I wanted to create a small OG renderrer for our organization's documentation page since it's also being hosted on CF, but I can't get "local" (to the project) images to work at all.
I'm building on top of the official Vite plugin guide, I have just one entry file that's returning the
ImageResponse, and a pre-made background image in apublicdirectory. It shows up just fine during local development. But when I deploy it to CF, I only get the template content with no background image using the following setup:All I get in CF is an error message reading
when I check the logs.
I've tried using the URL for a
backgroundImagestyle and a separateimgtag, and a whole bunch of other more random attempts out of slight desperation, but nothing got me closer to getting it working. I've checked that the background image itself is available in the path specified, but I can't seem to get it working in the image generation.But just giving it any regular external image URL in place of
bgImageUrlworks without issue