There are several users with corporate proxy issues that are faced at several layers of interacting with Cypress including during:
(a checkmark indicates that a fix is in #3531)
cy.visit()
npm install
cypress verify
(maybe?)baseUrl
is runningNODE_EXTRA_CA_CERTS
not being used in cy downloadNote: these are NOT cypress environment variables, but system/shell environment variables
Set HTTP_PROXY
and/or HTTPS_PROXY
to your corporate proxy
HTTP_PROXY=http://my-proxy-address cypress run
Set NO_PROXY
for localhost
to prevent it from hitting corporate proxy
NO_PROXY=localhost cypress run
For cy.visit()
For Download
CYPRESS_BINARY_VERSION
.For accessing 'Runs' tab in Test Runner
setting the environment variables was very helpful for the npm install on Mac. thx for workaround
Tried setting env using cross-env HTTPS_PROXY=<my corp proxy>
as well as HTTP_PROXY
, but request to external resource gets http 407
. I am using cntlm and set proxy to go through cntlm, but still unable to get CDN resources, e.g. google fonts
Tried do this:
PROXY_HTTP="http://proxy.adress" PROXY_HTTPS="https://proxy.adress" npx cypress run --spec cypress/integration/ah-ui.js -b chrome
With electron too, added rules in extension, add extension with VPN, added proxy settings in chrome...
but it doesn't work for me - best result - I can open url in new tab.
In Cypress test I receive -
CypressError: cy.visit() failed trying to load:
https://mytestsite
The content-type of the response we received from your web server was:
> null
This was considered a failure because responses must have content-type: 'text/html'
I've read everything I can find on this issue and tried every suggested workaround but Cypress still cannot connect to websites through our corporate proxy.
When will this feature be implemented? It is a massive blocker for any possibility of adoption within our team.
@Rende11 See this comment regarding null
content-type responses https://github.com/cypress-io/cypress/issues/1727#issuecomment-389891098
Did you try to set the corporate proxy into npm config
? Like so: https://stackoverflow.com/a/33892578
Hi,
I am facing the same issue 403 Forbidden issue with an local application i.e. application running in localhost,
Error:
TEST
1
VISIT
http://localhost:4200/login
CypressError: cy.visit() failed trying to load:
http://localhost:4200/login
The response we received from your web server was:
> 403: Forbidden
This was considered a failure because the status code was not '2xx'.
If you do not want status codes to cause failures pass the option: 'failOnStatusCode: false'
I have tried by providing proxy configurations in the cypress.json
file, but no luck,
{
"env": {
"HTTP_PROXY": "http://my-proxy-address:port",
"HTTPS_PROXY": "http://my-proxy-address:port",
"NO_PROXY": "localhost"
},
"defaultCommandTimeout": 10000
}
Please let me know exact solution for this.
Thanks in advance.
@suryamangena Is the error coming from your application? What happens when you visit http://localhost:4200/login in your web browser?
FYI, you cannot set the *_PROXY
environment variables from cypress.json
. You'll need to define them in your shell.
On Mac or Linux, it's enough to do HTTP_PROXY=http://my-proxy-address:port NO_PROXY=localhost cypress open
If setting your environment variables does not fix it, there is currently not a released solution. I'm actively working on it though! :)
@flotwig, error is not coming from application. In my normal web browser, I am able to access the application without any issues in my company network. Problem is with cypress opened browser with same proxy settings.
I tried setting with environment variables in Windows machine, but no luck. Still i am seeing the same issue.
Eagerly waiting on new release with solution! :)
Thanks for the quick response.
@flotwig Same here. exactly the same behaviour. same problem. my application is working properly in my everyday browser, but when it comes to cypress, it can't access it. same for both chrome and headless browser.
I mapped localhost
and 127.0.0.1
to localhost.com
in my /etc/hosts
file and added localhost.com
as the base URL to Cypress.json
file. With this way, Cypress can access to my app without any problem.
Maybe this workaround gives you some insight into the problem.
Thanks,
@suryamangrna @alioguzhan do your companies us a PAC file? https://en.wikipedia.org/wiki/Proxy_auto-config I believe that was the blocker to why I can't use Cypress at my company. I can set the HTTP_PROXY vars fine but our Network has a PAC file to determine how to connect to various domains. If Cypress could use a PAC file like our browsers I think we could finally get it working in my corporate network.
Thanks @alioguzhan. I will give out a try on provided solution.
@NickStees, I hope so my company may using PAC configuration.
I have to confirm with IT team.
The code for this is done in cypress-io/cypress#3531, but has yet to be released.
We'll update this issue and reference the changelog when it's released.
Great to hear this is now pending release! I've recently started piloting Cypress at work with the goal of wider adoption and the speed issues we've been facing as a result of corporate proxy issues are the only thing currently holding us back.
Any idea when this might be released?
@rjd40 Soon. We have been working on the release - had to pause to fix some potential regressions in the pre-release. 馃
@jennifer-shehane Thanks for all the hard work on this, I have a quick question will this proxy improvement also include authentication for proxy? We have that use case since our corporate proxies require authentication with username and password.
@RicardoVaranda Yes, basic
proxy authentication will be supported, just pass the proxy like so: http://username:[email protected]
Released in 3.3.0
.
Cannot believe that setting a proxy can be this difficult :( - I have a corporate PAC file for a proxy and I tried setting the HTTP and HTTPS proxies through command prompt, nothing seems to work.
Agreed, I am not a developer, but the complexity might turn away many testers from setting up Cypress.
@sriram04144 Have you checked the proxy configuration docs? It explains how to work if all you have is a PAC file. You just need to set HTTP_PROXY
to the proxy you need for outbound Internet access.
https://docs.cypress.io/guides/references/proxy-configuration.html
This issue will be closed to further comment as the exact issue here was resolved and tested.
If you're experiencing a bug similar to this in Cypress or want enhanced functionality for Proxy support, please open a new issue with a fully reproducible example that we can run or explaining the feature you would like.
Most helpful comment
I've read everything I can find on this issue and tried every suggested workaround but Cypress still cannot connect to websites through our corporate proxy.
When will this feature be implemented? It is a massive blocker for any possibility of adoption within our team.