fix(nextjs): pdf export endpoint

This commit is contained in:
sauravniraula 2025-07-21 17:43:03 +05:45
parent 8fac0673f0
commit 9f16249b41
No known key found for this signature in database
GPG key ID: 60FCC1B5A5E83326

View file

@ -13,25 +13,24 @@ export async function POST(req: NextRequest) {
return NextResponse.json({ error: "Missing Presentation ID" }, { status: 400 });
}
const browser = await puppeteer.launch({
headless: false,
headless: true,
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--disable-gpu',
'--disable-web-security',
'--window-size=1920,1080'
]
});
const page = await browser.newPage();
await page.goto(`http://localhost/pdf-maker?id=${id}`, { waitUntil: 'networkidle0',timeout: 80000 });
await page.goto(`http://localhost/pdf-maker?id=${id}`, { waitUntil: 'networkidle0', timeout: 80000 });
const pdfBuffer = await page.pdf({
printBackground: true,
width: "1280px",
height: "720px",
margin: { top: 0, right: 0, bottom: 0, left: 0 }
});
browser.close();
const sanitizedTitle = sanitizeFilename(title);