diff --git a/.changeset/unlucky-avocados-brake.md b/.changeset/unlucky-avocados-brake.md new file mode 100644 index 000000000..b64fc24c7 --- /dev/null +++ b/.changeset/unlucky-avocados-brake.md @@ -0,0 +1,5 @@ +--- +'@astrojs/cloudflare': patch +--- + +fixes `AdvancedRuntime` & `DirectoryRuntime` types to work woth Cloudflare caches diff --git a/packages/integrations/cloudflare/src/entrypoints/server.advanced.ts b/packages/integrations/cloudflare/src/entrypoints/server.advanced.ts index 957c1791d..471ca5270 100644 --- a/packages/integrations/cloudflare/src/entrypoints/server.advanced.ts +++ b/packages/integrations/cloudflare/src/entrypoints/server.advanced.ts @@ -1,4 +1,8 @@ -import type { Request as CFRequest, ExecutionContext } from '@cloudflare/workers-types'; +import type { + Request as CFRequest, + ExecutionContext, + CacheStorage, +} from '@cloudflare/workers-types'; import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; import { getProcessEnvProxy, isNode } from '../util.js'; @@ -16,7 +20,7 @@ export interface AdvancedRuntime { waitUntil: (promise: Promise) => void; env: Env & T; cf: CFRequest['cf']; - caches: typeof caches; + caches: CacheStorage; }; } @@ -50,7 +54,7 @@ export function createExports(manifest: SSRManifest) { }, env: env, cf: request.cf, - caches: caches, + caches: caches as unknown as CacheStorage, }, }; diff --git a/packages/integrations/cloudflare/src/entrypoints/server.directory.ts b/packages/integrations/cloudflare/src/entrypoints/server.directory.ts index 3542279b0..ada773bf6 100644 --- a/packages/integrations/cloudflare/src/entrypoints/server.directory.ts +++ b/packages/integrations/cloudflare/src/entrypoints/server.directory.ts @@ -1,4 +1,4 @@ -import type { Request as CFRequest, EventContext } from '@cloudflare/workers-types'; +import type { Request as CFRequest, EventContext, CacheStorage } from '@cloudflare/workers-types'; import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; import { getProcessEnvProxy, isNode } from '../util.js'; @@ -6,13 +6,12 @@ import { getProcessEnvProxy, isNode } from '../util.js'; if (!isNode) { process.env = getProcessEnvProxy(); } - export interface DirectoryRuntime { runtime: { waitUntil: (promise: Promise) => void; env: EventContext['env'] & T; cf: CFRequest['cf']; - caches: typeof caches; + caches: CacheStorage; }; } @@ -48,7 +47,7 @@ export function createExports(manifest: SSRManifest) { }, env: context.env, cf: request.cf, - caches: caches, + caches: caches as unknown as CacheStorage, }, };