Skip to content

Commit

Permalink
add: h & w as query params with fallback case
Browse files Browse the repository at this point in the history
  • Loading branch information
KukretiShubham committed Nov 11, 2024
1 parent 719650c commit 33c1019
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/pages/api/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
})

Expand Down

0 comments on commit 33c1019

Please sign in to comment.