From 33c1019d92bbb3acc73489b7e07653f31dca2046 Mon Sep 17 00:00:00 2001 From: Shubham Kukreti <57281769+KukretiShubham@users.noreply.github.com> Date: Mon, 11 Nov 2024 20:29:42 +0530 Subject: [PATCH] add: h & w as query params with fallback case --- src/pages/api/generate.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pages/api/generate.ts b/src/pages/api/generate.ts index abedfe8..8797186 100644 --- a/src/pages/api/generate.ts +++ b/src/pages/api/generate.ts @@ -25,7 +25,11 @@ const serverOptions = { } export const GET: APIRoute = async ({ url }) => { - const isDev = url.searchParams.get('dev') === 'true' + const { isDev, height, width } = { + isDev: url.searchParams.get('dev') === 'true', + height: url.searchParams.get('h'), + width: url.searchParams.get('w') + }; const options = isDev ? Localoptions : serverOptions try { @@ -46,8 +50,8 @@ export const GET: APIRoute = async ({ url }) => { // set the viewport size await page.setViewport({ - width: 1920, - height: 1080, + width: width ? Math.abs(parseInt(width)) : 1920, + height: height ? Math.abs(parseInt(height)) : 1080, deviceScaleFactor: 1, })