Puppeteer does not work on vercel plattform #30034
-
What version of Next.js are you using?11.1.2 What version of Node.js are you using?14.16.1 What browser are you using?Chrome What operating system are you using?Windows How are you deploying your application?npm run build Describe the BugI am using puppeteer in my API routes. I basically go to a page and generate a pdf file and sent an email. I get a 500 error code with following message:
Expected BehaviorI expect to have a successful call so that puppeteer can generate a pdf from my page URL. To ReproduceYou can probably reproduce this creating an api file and calling that using fetch or axios.
|
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 3 replies
-
Hey! I think you need https://www.npmjs.com/package/chrome-aws-lambda to get this working |
Beta Was this translation helpful? Give feedback.
-
@neg4n Hi thanks for your answer I will try to update it this evening, do you know why this is happening. Is this due to running it on a serverless function? |
Beta Was this translation helpful? Give feedback.
-
Ok so I had to tweak a few things, took me hours. For this usecase I did create a blogpost which explains the solution in detail. |
Beta Was this translation helpful? Give feedback.
-
Are there any workaround for this issue ? Still I am not able to run the puppeteer in vercel. I have the chrome-aws-lambda that exceeds the allowed serverless function size. I hope we would be running into the same issue even if we use the playwright-core as the issue is with the size of the chrome-aws-lambda itself. |
Beta Was this translation helpful? Give feedback.
-
This is an answer just to brainstorm ideas. It could be helpful for other people. I am just kinda lazy to try this, but I guess there are two solutions I think of:
I find these two good approaches to generate your PDF, but if there is an API route that could run puppeteer in production that will be much better. |
Beta Was this translation helpful? Give feedback.
-
anyone know how use puppeteer on nextjs 13? |
Beta Was this translation helpful? Give feedback.
-
I tried lots of solutions, none of them worked until i found this, https://www.npmjs.com/package/@sparticuz/chromium. Hope it works! |
Beta Was this translation helpful? Give feedback.
Ok so I had to tweak a few things, took me hours. For this usecase I did create a blogpost which explains the solution in detail.
Puppeteer with NextJS on Vercel