Skip to content

Commit

Permalink
fix(cloudflare-pages): handle assets only for get requests (#968)
Browse files Browse the repository at this point in the history
* fix: unable to handle non-GET request in cloudflare page

* fix: guard with `GET` method

---------

Co-authored-by: DanSnow <dododavid006@gmail.com>
Co-authored-by: Alex Pan <alex@storipress.com>
  • Loading branch information
3 people authored Feb 21, 2023
1 parent c82287a commit e47ffa0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/runtime/entries/cloudflare-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e47ffa0

Please sign in to comment.