From 8c8ca877d306ffe845f94fc8008c4eeb399d4185 Mon Sep 17 00:00:00 2001 From: Radu Date: Mon, 19 Sep 2022 04:08:37 +0200 Subject: [PATCH] [fix] return 404 instead of 200 for stale assets --- packages/adapter-cloudflare/src/worker.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; } };