Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix file uploading for infractions
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent eda287c commit f5b76b6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions functions/api/infractions/new.ts
Expand Up @@ -77,6 +77,12 @@ export async function onRequestPost(context: RequestContext) {
// @ts-expect-error
const files: File[] = body.keys().find((key) => key.match(/^files\[\d]$/));
const urlPromises = [];
const origin = context.request.headers.get("Origin");

if (!origin)
return new Response('{"error":"Origin header missing"}', {
status: 400,
});

for (const file of files) {
if (!allowedFileTypes.includes(file.type))
Expand All @@ -97,6 +103,7 @@ export async function onRequestPost(context: RequestContext) {
attachmentKey,
file.size,
(allowedFileTypes.find((t) => t === file.type) as string).split("/")[1],
origin,
),
);
}
Expand Down

0 comments on commit f5b76b6

Please sign in to comment.