withastro / adapters

Home for Astro's core maintained adapters
47 stars 26 forks source link

`@astro/cloudflare`: images from the public directory not being transformed when using `imageService: cloudflare` #164

Closed Wulfre closed 4 months ago

Wulfre commented 4 months ago

Astro Info

Astro                    v4.3.5
Node                     v20.11.0
System                   Linux (x64)
Package Manager          pnpm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             unocss
                         @astrojs/mdx
                         @astrojs/preact

Describe the Bug

Images being sourced from the public directory using relative paths, for example /images/image.png are not being transformed into their resized versions. I believe the issue is due to this line since the image is neither an ESM import, nor does it pass the isRemoteAllowed check, since it is not a remote path.

What's the expected result?

I expect these relative image paths to also be transformed to their respective /cdn-cgi/image paths so that they can be displayed at the intended size.

Link to Minimal Reproducible Example

Repo: https://github.com/Wulfre/wulf.re/tree/a589fccc63ce140541c40535ec3d61b85cec969f Deployment: https://1a32c833.wulf-re.pages.dev/

Participation

alexanderniebuhr commented 4 months ago

Thank you for bringing this issue to our attention. Please note that the behavior you've observed is intentional and is documented in our docs (https://docs.astro.build/en/guides/images/#where-to-store-images).

At this time, there are no plans to modify this behavior. As a workaround, you can use absolute full URLs for your images instead of relative URLs when accessing them from the public folder.