From e47ffa0af8f3bb12d6b5acd543a5a36b2c3a2780 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 21 Feb 2023 12:38:07 +0000 Subject: [PATCH] fix(cloudflare-pages): handle assets only for get requests (#968) * fix: unable to handle non-GET request in cloudflare page * fix: guard with `GET` method --------- Co-authored-by: DanSnow Co-authored-by: Alex Pan --- src/runtime/entries/cloudflare-pages.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/runtime/entries/cloudflare-pages.ts b/src/runtime/entries/cloudflare-pages.ts index 0751637984..c44c95eab6 100644 --- a/src/runtime/entries/cloudflare-pages.ts +++ b/src/runtime/entries/cloudflare-pages.ts @@ -21,9 +21,11 @@ interface CFRequestContext { export async function onRequest(ctx: CFRequestContext) { try { // const asset = await env.ASSETS.fetch(request, { cacheControl: assetsCacheControl }) - const asset = await ctx.next(); - if (asset.status !== 404) { - return asset; + if (ctx.request.method === "GET") { + const asset = await ctx.next(); + if (asset.status !== 404) { + return asset; + } } } catch { // Ignore