withastro / astro · Issue No. 17348
Astro v7.0.7
Node v26.4.0
System macOS (arm64)
Package Manager pnpm
Output static
Adapter @astrojs/cloudflare
Integrations none
No response
With the Cloudflare adapter configured with prerenderEnvironment: 'node', adding a prerendered catch-all route (src/pages/[...slug].astro) makes every image served through the /_image endpoint return a 500 in astro dev:
[ERROR] Could not import `cloudflare:workers`.
Error reference:
https://docs.astro.build/en/reference/errors/failed-to-load-module-ssr/
Location:
@astrojs/cloudflare/dist/entrypoints/image-transform-endpoint.js:1:21
Only two ingredients are needed, both in this repo's default config:
prerenderEnvironment: 'node' in the adapter options./_image.The default image service (cloudflare-binding) is already affected — no imageService option is required.
This breaks Starlight. Starlight injects exactly such a route (@astrojs/starlight/routes/static/index.astro, a prerendered /[...slug] catch-all), so any Starlight site using the Cloudflare adapter with prerenderEnvironment: 'node' has every dev-mode image 500 this way. The [...slug].astro in this repo is just a dependency-free stand-in for Starlight's route.
Clone https://github.com/kitschpatrol/repro-astro-cloudflare-image-dev-error
pnpm install
pnpm dev
Open http://localhost:4321/ — the image is broken. Requesting its /_image URL directly returns a 500 with FailedToLoadModuleSSR.
Then delete src/pages/[...slug].astro and request the same URL: 200, image/webp.
Skip the cloudflare:workers-based image endpoint in dev:
const isDev = process.argv.includes("dev");
adapter: cloudflare({
prerenderEnvironment: "node",
imageService: isDev ? "passthrough" : "cloudflare-binding",
}),
/_image requests in dev return the transformed image (200, image/webp), as they do when either ingredient is removed:
src/pages/[...slug].astro → image works.prerenderEnvironment: 'node' → image works.https://github.com/kitschpatrol/repro-astro-cloudflare-image-dev-error
Relay reads this issue against the repository's contribution signals: the files it is likely to touch, how the maintainers triage work this size, and what the first contribution would exercise.
The full analysis for this issue is still being assembled. Until then, the description above and the thread on GitHub are the most reliable context.