When I try to run Next js API on production Vercel I get this error
Failed to launch the browser process!\n/tmp/chromium: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory\n\n\nTROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md\n"
Locally everything works, but on production, I am having this error.
This is my code from API:
import chromium from "chrome-aws-lambda";
async function getBrowserInstance() {
const executablePath = await chromium.executablePath;
if (!executablePath) {
// running locally
const puppeteer = require("puppeteer");
return puppeteer.launch({
args: chromium.args,
headless: true,
defaultViewport: {
width: 1280,
height: 720,
},
ignoreHTTPSErrors: true,
ignoreDefaultArgs: ["--disable-extensions"],
});
}
return chromium.puppeteer.launch({
args: [
...chromium.args,
"--hide-scrollbars",
"--disable-web-security",
"--no-sandbox",
"--disable-setuid-sandbox",
],
defaultViewport: {
width: 1280,
height: 720,
},
executablePath: await chromium.executablePath,
headless: chromium.headless,
ignoreHTTPSErrors: true,
ignoreDefaultArgs: ["--disable-extensions"],
});
}