Setting proxy in browser using javascript and Cypress

Viewed 716

I am able to set the proxy in chrome browser using the below java code:

Proxy proxy = new Proxy();
ChromeOptions options = new ChromeOptions();

options.addArguments("--proxy-bypass-list=<-loopback>");
options.addArguments("--ignore-certificate-errors");

proxy.setHttpProxy("localhost:8090");
proxy.setFtpProxy("localhost:8090");
proxy.setSslProxy("localhost:8090");

options.setCapability(CapabilityType.PROXY, proxy);
options.setCapability(ChromeOptions.CAPABILITY, options);
options.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

webDriver = new ChromeDriver(options);

Now, I am using Cypress with javascript and want to do the same as I did above.

Any help will be appreciated.

1 Answers

For adding http proxy, you can set HTTP_PROXY environmental variable.

for mac:

export HTTP_PROXY = localhost:8090

for windows

set HTTP_PROXY = localhost:8090

And for ignoring certificate errors, you can disable chromeWebSecurity in cypress.json file

{ 
  "chromeWebSecurity": false
}

reference document

Related