schickling/chromeless

Issue using setExtraHTTPHeaders

blacelle opened this issue · 0 comments

Hello,

I tried using setExtraHTTPHeaders without success. It seems some other people are encountering the same issue:
#369

In local (i.e. not with Proxy in Lambda), I tried the following:

const chromeLauncher = require('chrome-launcher');
const Chromeless = require('chromeless').Chromeless;

const run = async () => {
  const chrome = await chromeLauncher.launch({
    port: 9222,
  });
  
  const chromeless = new Chromeless({
    launchChrome: false
  });
    
  return await makeScreenshot(chromeless);
};

const makeScreenshot = async chromeless => {
   await chromeless.goto('https://www.google.fr');
    await chromeless.setExtraHTTPHeaders({'Foo': 'Bar'});
    await chromeless.wait(2000).screenshot();
};

run();

I also tried by settings headers before the goto command, without success. It appears in DevTools my header is added on additional resources, but not for the main URL. It prevents the usage for Proxy-Authorization (which is my main usage for this).

In #337, I read

.setExtraHTTPHeaders set's additional HTTP headers on any requests made from within a page in Chrome

Does it mean works only once a URL have first been loaded ? .setExtraHTTPHeaders