diff --git a/package.json b/package.json index 7c20639..6b4063c 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "fathom-client": "^3.4.1", "got": "^12.0.3", "isomorphic-unfetch": "^3.1.0", + "ky": "^0.31.4", "lqip-modern": "^1.2.0", "next": "^12.3.1", "notion-client": "^6.13.11", diff --git a/pages/api/social-image.tsx b/pages/api/social-image.tsx index 33662c4..11b9888 100644 --- a/pages/api/social-image.tsx +++ b/pages/api/social-image.tsx @@ -2,6 +2,7 @@ import * as React from 'react' import { NextRequest } from 'next/server' import { ImageResponse } from '@vercel/og' +import ky from 'ky' import { api, apiHost } from '@/lib/config' import { NotionPageInfo } from '@/lib/types' @@ -30,15 +31,11 @@ export default async function OGImage(req: NextRequest) { return new Response('Invalid notion page id', { status: 400 }) } - const pageInfoRes = await fetch(`${apiHost}${api.getNotionPageInfo}`, { - method: 'POST', - body: JSON.stringify({ pageId }), - headers: { 'Content-Type': 'application/json' } - }) - if (!pageInfoRes.ok) { - return new Response(pageInfoRes.statusText, { status: pageInfoRes.status }) - } - const pageInfo: NotionPageInfo = await pageInfoRes.json() + const pageInfo = await ky + .post(`${apiHost}${api.getNotionPageInfo}`, { + json: { pageId } + }) + .json() console.log(pageInfo) return new ImageResponse( @@ -86,7 +83,7 @@ export default async function OGImage(req: NextRequest) { style={{ position: 'relative', width: 900, - height: 450, + height: 465, display: 'flex', flexDirection: 'column', border: '16px solid rgba(0,0,0,0.3)', @@ -133,7 +130,7 @@ export default async function OGImage(req: NextRequest) {