From 146c98a6a27526a4bad4be0b9e4e3d043770128c Mon Sep 17 00:00:00 2001 From: cp-sumi-k Date: Tue, 13 Feb 2024 11:24:04 +0530 Subject: [PATCH] Fix: puppeteer issue --- .gitignore | 1 + admin/Dockerfile | 2 ++ admin/src/api/post/content-types/post/lifecycles.js | 5 ++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e08af329..9061e7fa 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ node_modules .env #build +.strapi .cache build diff --git a/admin/Dockerfile b/admin/Dockerfile index 258111ed..aa862f20 100644 --- a/admin/Dockerfile +++ b/admin/Dockerfile @@ -5,6 +5,8 @@ WORKDIR /app # Bundle app source COPY . . +RUN apt-get update && apt-get install -y libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libasound2 + RUN mkdir public/uploads RUN yarn install --frozen-lockfile diff --git a/admin/src/api/post/content-types/post/lifecycles.js b/admin/src/api/post/content-types/post/lifecycles.js index d429c4a1..f5477535 100644 --- a/admin/src/api/post/content-types/post/lifecycles.js +++ b/admin/src/api/post/content-types/post/lifecycles.js @@ -352,7 +352,10 @@ async function generatePreview(event) { } async function runScraper(url) { - const browser = await puppeteer.launch({ headless: "old" }); + const browser = await puppeteer.launch({ + headless: true, + args: ["--no-sandbox"], + }); try { const page = await browser.newPage(); await page.goto(url);