From e150b8046c485d6ca2fbbd0fe2f905ad5b97dd36 Mon Sep 17 00:00:00 2001 From: James Opstad <13586373+jamesopstad@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:03:06 +0000 Subject: [PATCH 1/3] Removed 405 response from unstable_canFetch --- packages/workers-shared/asset-worker/src/index.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/workers-shared/asset-worker/src/index.ts b/packages/workers-shared/asset-worker/src/index.ts index 3eb6439596ff..13fd18205b59 100644 --- a/packages/workers-shared/asset-worker/src/index.ts +++ b/packages/workers-shared/asset-worker/src/index.ts @@ -117,9 +117,8 @@ export default class extends WorkerEntrypoint { } } - async unstable_canFetch(request: Request): Promise { + async unstable_canFetch(request: Request): Promise { const url = new URL(request.url); - const method = request.method.toUpperCase(); const decodedPathname = decodePath(url.pathname); const intent = await getIntent( decodedPathname, @@ -129,10 +128,6 @@ export default class extends WorkerEntrypoint { }, this.unstable_exists.bind(this) ); - // if asset exists but non GET/HEAD method, 405 - if (intent && ["GET", "HEAD"].includes(method)) { - return new MethodNotAllowedResponse(); - } if (intent === null) { return false; } From 2595a2b6a0c4e0c7945a2b2b8cc5e86d8023a04c Mon Sep 17 00:00:00 2001 From: James Opstad <13586373+jamesopstad@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:15:02 +0000 Subject: [PATCH 2/3] Removed unused import --- packages/workers-shared/asset-worker/src/index.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/workers-shared/asset-worker/src/index.ts b/packages/workers-shared/asset-worker/src/index.ts index 13fd18205b59..34276e72a82d 100644 --- a/packages/workers-shared/asset-worker/src/index.ts +++ b/packages/workers-shared/asset-worker/src/index.ts @@ -5,10 +5,7 @@ import { Analytics } from "./analytics"; import { AssetsManifest } from "./assets-manifest"; import { applyConfigurationDefaults } from "./configuration"; import { decodePath, getIntent, handleRequest } from "./handler"; -import { - InternalServerErrorResponse, - MethodNotAllowedResponse, -} from "./responses"; +import { InternalServerErrorResponse } from "./responses"; import { getAssetWithMetadataFromKV } from "./utils/kv"; import type { AssetConfig, UnsafePerformanceTimer } from "../../utils/types"; import type { ColoMetadata, Environment, ReadyAnalytics } from "./types"; From a311397df593da7d99f153547e34d3454bf00723 Mon Sep 17 00:00:00 2001 From: James Opstad <13586373+jamesopstad@users.noreply.github.com> Date: Thu, 7 Nov 2024 17:08:13 +0000 Subject: [PATCH 3/3] Added changeset --- .changeset/metal-flies-cross.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/metal-flies-cross.md diff --git a/.changeset/metal-flies-cross.md b/.changeset/metal-flies-cross.md new file mode 100644 index 000000000000..83a72ebc73f3 --- /dev/null +++ b/.changeset/metal-flies-cross.md @@ -0,0 +1,5 @@ +--- +"@cloudflare/workers-shared": patch +--- + +Remove incorrect logic in Asset Worker.