diff --git a/lib/config.ts b/lib/config.ts index 32a1b06..25e27bc 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -125,8 +125,9 @@ export const redisNamespace: string | null = getEnv( export const isServer = typeof window === 'undefined' export const port = getEnv('PORT', '3000') -export const host = isDev - ? `http://localhost:${port}` +export const host = isDev ? `http://localhost:${port}` : `https://${domain}` +export const apiHost = isDev + ? host : `https://${process.env.VERCEL_URL || domain}` export const apiBaseUrl = `/api` diff --git a/pages/api/social-image.tsx b/pages/api/social-image.tsx index daac459..610270f 100644 --- a/pages/api/social-image.tsx +++ b/pages/api/social-image.tsx @@ -3,7 +3,7 @@ import { ImageResponse } from '@vercel/og' import { NextRequest } from 'next/server' import { NotionPageInfo } from 'lib/types' -import { host, api } from 'lib/config' +import { apiHost, api } from 'lib/config' const interRegularFontP = fetch( new URL('../../public/fonts/Inter-Regular.ttf', import.meta.url) @@ -29,7 +29,7 @@ export default async function OGImage(req: NextRequest) { return new Response('Invalid notion page id', { status: 400 }) } - const pageInfoRes = await fetch(`${host}${api.getNotionPageInfo}`, { + const pageInfoRes = await fetch(`${apiHost}${api.getNotionPageInfo}`, { method: 'POST', body: JSON.stringify({ pageId }), headers: { 'Content-Type': 'application/json' }