fix: cloudflare passthrough image service endpoint#15794
Conversation
🦋 Changeset detectedLatest commit: 89730c2 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
What are we fixing @OliverSpeir ? It's notclear from the description. And since we don't have an issue, we should explain it. |
|
@ematipico here's my message about it from discord as context
I hadn't filed an issue because I wasn't familiar with the process. |
Changes
Adds a Cloudflare-specific
/_imagepassthrough endpoint that serves local assets viaenv.ASSETSand proxies remote images via fetch.When using imageService: 'passthrough' or imageService: 'compile' currently, the
/_imageendpoint falls back to Astro's generic endpoint which loads local assets by fetching the same origin.In Cloudflare Workers, without the global_fetch_strictly_public compatibility flag (not included in the default generated wrangler config), same-origin fetch are routed back through the Worker's own fetch handler rather than the CDN. Since the Worker doesn't handle /_astro/ paths, the request returns 404.
This bypasses HTTP routing entirely (for local assets) and works regardless of compatibility flags.
Testing
manually with
pnpm previewDocs
n/a