From 7b73d646a51df8e0aeabd9965241ca457f8d9d6f Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:49:21 -0400 Subject: [PATCH] Fix middleware routing issue --- functions/api/appeals/[id]/_middleware.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/functions/api/appeals/[id]/_middleware.ts b/functions/api/appeals/[id]/_middleware.ts index 6b29edb..15376e9 100644 --- a/functions/api/appeals/[id]/_middleware.ts +++ b/functions/api/appeals/[id]/_middleware.ts @@ -1,4 +1,10 @@ export async function onRequestPost(context: RequestContext) { + const { pathname } = new URL(context.request.url); + + // Fix weirdo routing issue + if (pathname.endsWith("/submit") || pathname.endsWith("/toggle")) + return await context.next(); + const { permissions } = context.data.current_user; if (!(permissions & (1 << 0)) && !(permissions & (1 << 11))) @@ -14,7 +20,7 @@ export async function onRequestPost(context: RequestContext) { context.data.targetId = id; - if (!new URL(context.request.url).pathname.endsWith("/ban")) { + if (!pathname.endsWith("/ban")) { const key = await context.env.DATA.get(`appeal_${id}`); if (!key)