Skip to content

Commit

Permalink
Set Allow header for 405 requests (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
flakey5 authored Aug 22, 2023
1 parent 2770943 commit 299cc1c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ ${htmlList.join("\n")}
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
const allowedMethods = ["GET", "HEAD", "OPTIONS"];
if (allowedMethods.indexOf(request.method) === -1) return new Response("Method Not Allowed", { status: 405 });
if (allowedMethods.indexOf(request.method) === -1) {
return new Response("Method Not Allowed", { status: 405, headers: { "allow": allowedMethods.join(", ") } });
}

if (request.method === "OPTIONS") {
return new Response(null, { headers: { "allow": allowedMethods.join(", ") } })
Expand Down

0 comments on commit 299cc1c

Please sign in to comment.