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) }) }