This example is to be used with the Browserless template
Create a reference variable on your Railway service that you deploy your app to
BROWSER_WS_ENDPOINT=${{Browserless.BROWSER_WS_ENDPOINT}}
Then use process.env.BROWSER_WS_ENDPOINT
in code
const browser = await puppeteer.launch();
const browser = await puppeteer.connect({ browserWSEndpoint: process.env.BROWSER_WS_ENDPOINT });
The rest of your JS/TS code remains the same with no other changes required.
-
Switch the
puppeteer
dependency out forpuppeteer-core
-
npm uninstall puppeteer
->npm install puppeteer-core
-
puppeteer-core
will not auto install Chrome or Chromium
-
-
Use this repositories
nixpacks.toml
file in your project- The empty
aptPkgs
array will prevent Railway from installing the now unwanted Chrome dependencies
- The empty