From cc0ee2ee3d614204cfa99cdc2651add186aa8634 Mon Sep 17 00:00:00 2001 From: Rupam Kairi Date: Wed, 22 Jan 2025 17:36:04 +0530 Subject: [PATCH] Short cicuiting OPTIONS call with empty response. --- apps/server/src/pages/api/v1/fires/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/server/src/pages/api/v1/fires/index.ts b/apps/server/src/pages/api/v1/fires/index.ts index 5f7f33d2..0c34cb0f 100644 --- a/apps/server/src/pages/api/v1/fires/index.ts +++ b/apps/server/src/pages/api/v1/fires/index.ts @@ -27,8 +27,8 @@ export default async function firesBySiteHandler( // checkMethods(req, res, ["GET"]); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - if (!["OPTIONS", "GET"].includes(req.method!)) { - if (req.method === 'OPTIONS') { return res.status(200).send("Ok") } + if (req.method === 'OPTIONS') { return res.status(200).end() } + if (!["GET"].includes(req.method!)) { return res.status(405).json({ message: "Method Not Allowed" }); }