Skip to content

Commit

Permalink
Merge pull request #14 from LewisDaleUK/fix/fix-chromium-errors
Browse files Browse the repository at this point in the history
Enable puppeteer and Chromium to work with latest versions of Node.
  • Loading branch information
zachleat authored Jul 18, 2024
2 parents 59dfec8 + 804ed93 commit d71de22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions functions/screenshot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { builder } = require("@netlify/functions");
const chromium = require("chrome-aws-lambda");
const chromium = require("@sparticuz/chromium");
const puppeteer = require("puppeteer-core");

function isFullUrl(url) {
try {
Expand All @@ -15,7 +16,7 @@ async function screenshot(url, { format, viewport, dpr = 1, withJs = true, wait,
// Must be between 3000 and 8500
timeout = Math.min(Math.max(timeout, 3000), 8500);

const browser = await chromium.puppeteer.launch({
const browser = await puppeteer.launch({
executablePath: await chromium.executablePath,
args: chromium.args,
defaultViewport: {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"homepage": "https://github.com/11ty/api-screenshot#readme",
"dependencies": {
"@netlify/functions": "^1.0.0",
"chrome-aws-lambda": "^10.1.0",
"puppeteer-core": "^10.1.0"
"@sparticuz/chromium": "^108.0.0",
"puppeteer-core": "^19.2.2"
}
}

0 comments on commit d71de22

Please sign in to comment.