Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix middleware routing issue
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 95bda99 commit 7b73d64
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion 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)))
Expand All @@ -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)
Expand Down

0 comments on commit 7b73d64

Please sign in to comment.