so am using puppeteer.connect method and am trying to goto chrome://version to extract the user-agent that is being used by puppeteer , so when the headless mode is false it would do fine but when trying headless mode it would give this error
Error: net::ERR_INVALID_URL at chrome://version
Code example :
browser = await puppeteer.connect({ browserURL, defaultViewport: null });
page = await browser.newPage();
await page.goto('chrome://version');
const useragent = await page.waitForSelector('#useragent');
const UserAgent = await page.evaluate(element => element.innerText, useragent);
It happens because Chrome specifically blocks local file access this way for security reasons.
Anyway, you don't need to open the version page to get a user agent. Because there is a method for it:
await browser.userAgent();
It returns: <Promise<string>>
Promise which resolves to the browser's original user agent.