#171757a7d879 Thanks @astrobot-houston! - Fixes astro dev OOM crashes for @astrojs/cloudflare users on Vite 8 by migrating the frontmatter scan plugin to Rolldown-compatible options.
#171870db4b57 Thanks @matthewp! - Fixes React invalid hook warning during cold SSR optimizer reload when using ClientRouter
[!WARNING]
This provider requires the Cloudflare Workers Cache feature, which is currently in private beta. It is opt-in: nothing changes unless you import cacheCloudflare() and set it as your provider. But without beta access it does not work and should not be used. Cloudflare Workers run in front of the cache, so cached responses are never served, and calling cache.invalidate() throws an error.
Setup
Import cacheCloudflare() from @astrojs/cloudflare/cache and set it as your cache provider:
The adapter automatically enables the Worker caching layer when a Cloudflare cache provider is configured. No manual wrangler.jsonc changes are needed.
Caching responses
Use Astro.cache.set() in your pages and API routes to cache responses. The provider sets Cloudflare-CDN-Cache-Control and Cache-Tag headers, which are read by Cloudflare’s built-in caching layer. Cache hits bypass Worker execution entirely, meaning your Worker is not invoked for cached responses.
Static assets under _astro can be cached to improve performance. The adapter now automatically injects a Cache-Control header at build time when possible.
🐞 Patch Changes
#169687a5c001 Thanks @astrobot-houston! - Fixes a build crash when using experimental.advancedRouting with a custom fetchFile that statically imports cf from @astrojs/cloudflare/fetch. The circular dependency between @astrojs/cloudflare/fetch and astro/app/entrypoint caused createApp or createGetEnv to be undefined at module evaluation time. Initialization is now deferred to the first cf() call, breaking the cycle.
#16990ebeb830 Thanks @ocavue! - Fixes a build crash when using experimental.advancedRouting with a custom fetchFile that statically imports cf from @astrojs/cloudflare/fetch. The circular dependency between @astrojs/cloudflare/fetch and astro/app/entrypoint caused createApp or createGetEnv to be undefined at module evaluation time. Initialization is now deferred to the first cf() call, breaking the cycle.
#16671fd926fd Thanks @alexanderniebuhr! - Removes deprecations warnings added in Astro v6 for Cloudflare specific Astro.locals properties.
Both handlers configure SESSION KV bindings, static asset serving via the ASSETS binding, locals.cfContext, client address, waitUntil, and prerendered error page fetch.
🐞 Patch Changes
#16868f9bae95 Thanks @helio-cf! - Fixes user options passed to cloudflare({...}) (remoteBindings, inspectorPort, persistState, configPath, auxiliaryWorkers) being silently ignored during astro preview. The adapter now resolves the full @cloudflare/vite-plugin config once at integration setup time and reuses that single resolved value across the dev/build plugin, the prerenderer’s preview server, and the astro preview entrypoint, so user options can no longer be dropped at one of the call sites.
#164684cff3a1 Thanks @matthewp! - Fixes static Cloudflare builds with server islands or image endpoints that failed at preview time due to mismatched output directories.
#16769428cb1b Thanks @astrobot-houston! - Forwards user-provided optimizeDeps settings (exclude, include, esbuildOptions.loader) to SSR/prerender environments. Previously, top-level vite.optimizeDeps in the Astro config was silently ignored for server environments because Vite 6 scopes it to client-only and the adapter’s configEnvironment hook did not forward it. This caused packages with non-standard file types (e.g. .data files) to fail during dev-mode dependency optimization with errors like “No loader is configured for ‘.data’ files”.
#16801d619277 Thanks @ematipico! - Reverts a change to the esbuild dep-scan plugin that caused astro check and astro build to fail by making esbuild incorrectly bundle virtual: modules (e.g. from expressive-code)
#16708bb709ff Thanks @fkatsuhiro! - Fixed a bug where a cascade of reloads would cause the page to crash during the first visit when building or developing with Cloudflare SSR in Astro v6 due to dependency loading issues.
#167072ff3f8f Thanks @helio-cf! - Fixes remoteBindings: false being ignored during astro build. The Cloudflare prerenderer’s internal Vite preview server now receives the user’s adapter options, so remote-flagged bindings (e.g. a D1 database with remote: true in wrangler.toml) are emulated locally during build, matching the existing astro dev behavior.
#1665298c32cc Thanks @greatjourney589! - Fixes user-declared KV namespace bindings being duplicated in the generated dist/server/wrangler.json, which caused wrangler validation to fail with “ assigned to multiple KV Namespace bindings.” The Astro Cloudflare config customizer now returns only the auto-injected SESSION binding and lets @cloudflare/vite-plugin merge it with the user’s wrangler config, instead of pre-merging the user’s bindings into the output.
#162724f9521e Thanks @barry3406! - Fixes .astro files failing with No matching export in "html:..." for import "default" when default-imported from a .ts file
#157239256345 Thanks @rururux! - Fixes an issue where the <Prism /> component failed to work in Cloudflare Workers.
#165191b1c218 Thanks @louisescher! - Adds support for redirecting URLs in remote image optimization.
Previously, when a remote image URL meant to be optimized by Astro led to a redirect, Astro would fail silently and ignore the redirect. Now, Astro tracks up to 10 redirects for these images. If any of the redirects are not covered by a pattern in image.remotePatterns or a domain in image.domains, Astro will fail with a helpful error message.
In the following example, the first image would be loaded successfully, while the second would lead to Astro throwing an error:
exportdefaultdefineConfig({
image: {
domains: ['example.com', 'cdn.example.com'],
},
});
{
/* Redirects to https://cdn.example.com/assets/image.png: */
}
<Image
src="https://example.com/assets/image.png"
width="1920"
height="1080"
alt="An example image."
/>;
{
/* Redirects to https://malicious.com/image.png: */
}
<Image
src="https://example.com/bad-image.png"
width="1920"
height="1080"
alt="An example image."
/>;
In cases where all redirects to HTTPS hosts should be trusted, the following configuration for image.remotePatterns can be used:
#16187fe58071 Thanks @gllmt! - Adds a waitUntil option to the RenderOptions so that adapters can forward runtime background-task hooks to Astro.
When provided by an adapter, runtime cache providers receive context.waitUntil in
CacheProvider.onRequest(), which allows background cache work such as stale-while-revalidate
without blocking the response. The Cloudflare adapter now forwards
ExecutionContext.waitUntil to this API.
#16290a49637a Thanks @ViVaLaDaniel! - Ensures that server.allowedHosts (and vite.preview.allowedHosts) configuration is respected when using astro preview with the @astrojs/cloudflare adapter. This improves security by preventing DNS rebinding attacks when previewing Cloudflare builds locally.
#164984efe020 Thanks @matthewp! - Fixes the dependency scan failing with “No matching export for import ‘default’” when a .ts file default-imports an .astro component
The esbuild scan plugin now includes export default {} in its output for .astro files, preventing the scan from failing and ensuring all dependencies are discovered ahead of time.
#164588cb1f42 Thanks @matthewp! - Fixes Cloudflare dev and build failures caused by @cloudflare/vite-plugin defaulting compatibility_date to today’s date, which can exceed the maximum date supported by the bundled workerd binary