From c3c798d67013c5e3febc705ffbc9ec80ac72bdc5 Mon Sep 17 00:00:00 2001 From: arvinxx Date: Fri, 18 Aug 2023 00:18:06 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20fix=20edge=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/v1/index.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/api/v1/index.ts b/api/v1/index.ts index b0edaf4..a27bc4b 100644 --- a/api/v1/index.ts +++ b/api/v1/index.ts @@ -1,15 +1,13 @@ -import fetchContent from './_utils'; - -export const config = { - runtime: 'edge', -}; +import type { VercelRequest, VercelResponse } from '@vercel/node'; -export default async (req: Request) => { - if (req.method !== 'POST') return new Response('Method Not Allowed', { status: 405 }); +import fetchContent from './_utils'; - const args = (await req.json()) as { url: string }; +export default async function handler(req: VercelRequest, res: VercelResponse) { + if (req.method !== 'POST') { + res.status(405); + } - const result = await fetchContent(args); + const result = await fetchContent(req.body); - return new Response(JSON.stringify(result)); -}; + res.send(result); +}