From 39a3843c561f4fb1ed85b4ef1f1afa6ded707e90 Mon Sep 17 00:00:00 2001 From: Robert McGovern Date: Thu, 7 Mar 2024 11:11:22 +0000 Subject: [PATCH] added config so can specify location of browser, mostly for arm linux where the version that came with puppeteer didn't load --- image-generator.cjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/image-generator.cjs b/image-generator.cjs index a030568..9784013 100644 --- a/image-generator.cjs +++ b/image-generator.cjs @@ -4,6 +4,7 @@ const express = require("express"); const { parentPort, workerData } = require("worker_threads"); const path = require("path"); +require("dotenv").config(); const folderToServe = "/Users/tarasis/Programming/websites/rmcg.dev/www/FrontendMentor/newbie/social-links-profile/"; @@ -30,7 +31,11 @@ const dynamicServer = dynamicPage.listen(0, async () => { const dynamicPort = dynamicServer.address().port; console.log(`Dynamic server is running at http://localhost:${dynamicPort}`); - const browser = await puppeteer.launch(); + const browserLocation = process.env.BROWSER || ""; + const browser = await puppeteer.launch({ + headless: true, + executablePath: browserLocation, + }); const page = await browser.newPage(); await page.goto(`http://localhost:${dynamicPort}`);