From 6516a2771d9aa01f88dc232523930847590bba62 Mon Sep 17 00:00:00 2001 From: sueun-dev <57546981+sueun-dev@users.noreply.github.com> Date: Mon, 18 May 2026 12:49:00 -0400 Subject: [PATCH] Fix API method guards --- pages/api/getContract.ts | 5 +++-- pages/api/getDynamicDoc.ts | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pages/api/getContract.ts b/pages/api/getContract.ts index 8630692b..eb825d7b 100644 --- a/pages/api/getContract.ts +++ b/pages/api/getContract.ts @@ -7,11 +7,12 @@ export default async function handler( res: NextApiResponse, ) { if (req.method !== 'GET') { - res.status(405) + res.setHeader('Allow', ['GET']) + return res.status(405).json({ error: 'Method Not Allowed' }) } const addr = req.query?.address as string const ethscan_resp = await etherscanGetSource(addr) const data = await ethscan_resp.json() - res.status(200).json(data) + return res.status(200).json(data) } diff --git a/pages/api/getDynamicDoc.ts b/pages/api/getDynamicDoc.ts index 605521c8..f63b5ee3 100644 --- a/pages/api/getDynamicDoc.ts +++ b/pages/api/getDynamicDoc.ts @@ -5,10 +5,11 @@ export default async function handler( req: NextApiRequest, res: NextApiResponse, ) { - if (req.method === 'POST') { - const { body } = req - res.status(200).json({ mdx: await serialize(body.content) }) - } else { - res.status(405) + if (req.method !== 'POST') { + res.setHeader('Allow', ['POST']) + return res.status(405).json({ error: 'Method Not Allowed' }) } + + const { body } = req + return res.status(200).json({ mdx: await serialize(body.content) }) }