diff --git a/packages/adapter-cloudflare/src/worker.js b/packages/adapter-cloudflare/src/worker.js index a31267aef944..1e4c882118eb 100644 --- a/packages/adapter-cloudflare/src/worker.js +++ b/packages/adapter-cloudflare/src/worker.js @@ -20,6 +20,7 @@ const worker = { // static assets if (pathname.startsWith(prefix)) { res = await env.ASSETS.fetch(req); + if (!res.ok) return res const cache_control = pathname.startsWith(prefix + 'immutable/') ? 'public, immutable, max-age=31536000' @@ -65,7 +66,7 @@ const worker = { // Writes to Cache only if allowed & specified pragma = res.headers.get('cache-control'); - return pragma ? Cache.save(req, res, context) : res; + return pragma && res.ok ? Cache.save(req, res, context) : res; } };