chromium (_common/browser.js)

web-check · api/_common/browser.js · javascript · MIT
scraping, Scraping / Crawling

Module exposing: chromium, launchBrowser, openPage, closeBrowser, isBrowserMissing

// Source: https://github.com/lissy93/web-check | License: MIT | Copyright 2023 Alicia Sykes <https://github.com/lissy93>
// Provided via justclaw.it.com; keep this notice with the code.
import puppeteer from 'puppeteer-core';
import sparticuz from '@sparticuz/chromium';

export const chromium = sparticuz.default || sparticuz;

// Serverless launch args, minus the ones that turn off same-origin rules
const UNSAFE_ARGS = ['--disable-web-security', '--allow-running-insecure-content'];
const ARGS = chromium.args.filter((arg) => !UNSAFE_ARGS.includes(arg));

// Pick Chromium: CHROME_PATH, puppeteer's copy when self-hosted, or the serverless build
const chromiumPath = async () => {
  if (process.env.CHROME_PATH) return process.env.CHROME_PATH;
  if (process.env.WC_SERVER) return (await import('

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key