Skip to content

Commit

Permalink
Remove incorrect logic in Asset Worker (#7176)
Browse files Browse the repository at this point in the history
* Removed 405 response from unstable_canFetch

* Removed unused import

* Added changeset
  • Loading branch information
jamesopstad authored Nov 25, 2024
1 parent c808590 commit 476e5df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-flies-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudflare/workers-shared": patch
---

Remove incorrect logic in Asset Worker.
12 changes: 2 additions & 10 deletions packages/workers-shared/asset-worker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -117,9 +114,8 @@ export default class extends WorkerEntrypoint<Env> {
}
}

async unstable_canFetch(request: Request): Promise<boolean | Response> {
async unstable_canFetch(request: Request): Promise<boolean> {
const url = new URL(request.url);
const method = request.method.toUpperCase();
const decodedPathname = decodePath(url.pathname);
const intent = await getIntent(
decodedPathname,
Expand All @@ -129,10 +125,6 @@ export default class extends WorkerEntrypoint<Env> {
},
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;
}
Expand Down

0 comments on commit 476e5df

Please sign in to comment.