Headless chrome proxy server settings
google-chrome, google-chrome-devtools, headless-browser, lighthouse, node.js
Solution
I tried it using regular `exec` and it works just fine, here is my snippet:
const exec = require('child_process').exec;
function launchHeadlessChrome(url, callback) {
// Assuming MacOSx.
const CHROME = '/Users/h0x91b/Desktop/Google\\ Chrome\\ Beta.app/Contents/MacOS/Google\\ Chrome';
exec(`${CHROME} --headless --disable-gpu --remote-debugging-port=9222 --proxy-server=127.0.0.1:8888 ${url}`, callback);
}
launchHeadlessChrome('https://www.chromestatus.com', (err, stdout, stderr) => {
console.log('callback', err, stderr, stdout)
});
Then I navigated to http://localhost:9222 and in Developer tools I see :
Proxy connection Error, which is ok, because I don't have proxy on this port, but this means that the Chrome tried to connect via proxy...
BTW Chrome version is 59.
Have checked the source code https://github.com/GoogleChrome/lighthouse/blob/master/chrome-launcher/chrome-launcher.ts#L38-L44
I see no `additionalFlags` here, there is only `chromeFlags` try to use it...
Problem
Could anyone help me with setting proxy-server for headless chrome while using the lighthouse chrome launcher in Node.js as mentioned here ``` const launcher = new ChromeLauncher({ port: 9222, autoSelectChrome: true, // False to manually select which Chrome install. additionalFlags: [ '--window-size=412,732', '--disable-gpu', '--proxy-server="IP:PORT"', headless ? '--headless' : '' ] }); ``` However, the above script does not hit my proxy server at all. Chrome seems to fallback to DIRECT:// connections to the target website. One other resource that talks about using HTTP/HTTPS proxy server in the context of headless chrome is this. But it does not give any example of how to use this from Node.js.