diff --git a/src/routes/og/merchant/+server.ts b/src/routes/og/merchant/+server.ts index c6199cd..8c8271f 100644 --- a/src/routes/og/merchant/+server.ts +++ b/src/routes/og/merchant/+server.ts @@ -4,19 +4,24 @@ import { generateImage } from '../generateImage'; import type { RequestHandler } from './$types'; export const GET: RequestHandler = async ({ url }) => { - const lat = url.searchParams.get('lat'); - const lon = url.searchParams.get('lon'); + try { + const lat = url.searchParams.get('lat'); + const lon = url.searchParams.get('lon'); - if (!lat || !lon) return new Response(undefined, { status: 418 }); + if (!lat || !lon) return new Response(undefined, { status: 418 }); - const component = MerchantOG.render({ lat, lon, STADIA_API_KEY }); + const component = MerchantOG.render({ lat, lon, STADIA_API_KEY }); - const image = await generateImage(component); + const image = await generateImage(component); - return new Response(image, { - headers: { - 'content-type': 'image/png', - 'cache-control': 'max-age=31449600' - } - }); + return new Response(image, { + headers: { + 'content-type': 'image/png', + 'cache-control': 'max-age=31449600' + } + }); + } catch (error) { + console.log(error); + return new Response(undefined, { status: 418 }); + } };