question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

puppeteer 1.11.0 ignore --proxy-server for localhost URLs

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: v1.11.0
  • Platform / OS version: macOS High Sierra
  • URLs (if applicable): None
  • Node.js version: v8.6.0

What steps will reproduce the problem?

  1. start a proxy on localhost on 8081
  2. start browserless with --proxy-server=localhost:8081
  3. use goto with an URL on localhost

The request will bypass the configured proxy although it worked up until v1.10.0.

If you use an url on some domain (ex: google.com) then the proxy will be used.

const puppeteer = require('puppeteer');
const { setupServer } = require('./test/helper');

(async () => {
  const proxy = await setupServer(8081);
  const server = await setupServer(80);

  const browser = await puppeteer.launch({
    args: [
      '--proxy-server=localhost:8081',
    ]
  });

  const page = await browser.newPage();

  try {
    const response = await page.goto('http://localhost/page.html');
    console.log('res', response.status());
  } catch (e) {
    console.log('err', e.message);
  }

  await browser.close();
  await proxy.stop();
  await server.stop();
})();

The setupServer was copied from puppeteer tests, I only added this:

  requests() {
    return this._requests;
  }

    reset() {
    this._requests = [];
    // rest of code
  }

  _onRequest(request, response) {
    this._requests.push(request.url);
    // rest of code
  }

For my own tests to verify that the request goes through the proxy I started which looks like:

  describe('HTTP proxy', () => {
    it('uses configured HTTP proxy', async () => {
      const proxy = await setupServer(8081);
      try {
        await fetch({ url: server.EMPTY_PAGE, http_proxy: 'localhost:8081' });
        expect(proxy.requests()).to.include(server.EMPTY_PAGE);
      } finally {
        await proxy.stop();
      }
    });
  });

What is the expected result?

  • The request to go trough the configured proxy

What happens instead?

  • The proxy is ignored

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
sethfowlercommented, Jan 2, 2019

@panthony If you’re on Chrome 72, you may be hitting the problem discussed in this Cypress bug report.

Apparently --proxy-bypass-list=<-loopback> will fix the issue.

0reactions
aslushnikovcommented, Jan 10, 2019

@panthony @sethfowler awesome, thanks for the investigation!

Or maybe add something somewhere, maybe in troubleshooting (although I’m just discovering this page)?

I’ve added this option to the //examples/proxy.js - should be good enough for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use proxy in puppeteer and headless Chrome?
Repository: https://github.com/Cuadrix/puppeteer-page-proxy ... To skip proxy simply call request.continue() conditionally.
Read more >
Puppeteer开发过程中遇到的问题及解决方案 - CSDN博客
--data-reduction-proxy-http-proxies ⊗ The semicolon-separated list of proxy server URIs to override the list of HTTP proxies returned by ...
Read more >
Make headless Chrome and Puppeteer use a proxy server
Apify's open-source proxy-chain on NPM enables you to run headless Chrome and Puppeteer over a proxy server that requires authentication.
Read more >
mozilla-central: changeset 571784 ...
+Puppeteer tests are located in [the `test` directory](https://github.com/puppeteer/puppeteer/blob/main/test/) and are written using Mocha. See [`test/README.md ...
Read more >
Http-proxy NPM - npm.io
createProxyServer ({target:'http://localhost:9000'}).listen(8000); // See (†) // // Create your target server // http.createServer(function (req, res) { res.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found