Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress cannot load pages behind a corporate proxy #672

Closed
getluke opened this issue Sep 20, 2017 · 49 comments

Comments

@getluke
Copy link

commented Sep 20, 2017

  • Operating System: Mac OS 10.12.6
  • Cypress Version: 0.20.1
  • Browser Version: Chrome v61

Is this a Feature or Bug?

Feature

Current behavior:

When running on a machine that requires a corporate proxy, cypress does not use the proxy settings and therefore cannot access and run tests on pages behind the proxy.

Desired behavior:

Cypress should respect the internal proxy settings of the network. From Brian Mann in Gitter:

"right i think its something we'll have to take into account and upgrade
cypress does not respect the internal proxy settings of the network
it would just work if we took that into account though"

Additional Info (images, stack traces, etc)

Resolving this would allow teams behind corporate proxies to adopt the software.

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented Sep 20, 2017

Related issue #584

@yuriMalakhov

This comment has been minimized.

Copy link

commented Oct 19, 2017

Thank you for the great product!

Any news or workarounds on using Cypress behind a corporate proxy?

@vjefri03

This comment has been minimized.

Copy link

commented Oct 20, 2017

Cypress is an extension on chrome. I was running into the same issue and getting 503. I fixed it by enabling permissions on the extension. Upper right hand where the three dots for settings
screen shot 2017-10-19 at 9 37 55 pm
go to extensions and allow permissions
screen shot 2017-10-19 at 9 37 35 pm

screen shot 2017-10-19 at 9 39 47 pm

@ayellamanchilli

This comment has been minimized.

Copy link

commented Oct 25, 2017

Thank you for the great product.

I am able to access all the general applications like facebook, gmail so on. Issue is with accessing my application which can be accessible only in my office network. I see runner is trying to invoke the URL but at the end gives an error 'Whoops there is no test to run'.

Other sample tests are running fine without any issues. I had a discussion with my IT team and they are not able to help me on this.

Any update on this issue??

@timothystone

This comment has been minimized.

Copy link

commented Nov 4, 2017

@getluke have you seen @vjefri03 suggestion?

@Jan10

This comment has been minimized.

Copy link

commented Nov 9, 2017

Same problem here.
image

@vjefri03 suggestion does not work for me.

@andrewleith

This comment has been minimized.

Copy link

commented Nov 20, 2017

Oddly, this works perfectly fine for me on a mac. I am VPN'd into my corporate network, which then forces me to use a proxy to go out to the internet.

My app loads just fine in Cypress, as do the resources coming off CDNs. I wonder why it would work for some of us and not others?

@jivimberg

This comment has been minimized.

Copy link

commented Nov 20, 2017

Similar setup here: mac with corporate VPN and proxy configured.

My app loads ok but CDN content times out.

@charch

This comment has been minimized.

Copy link

commented Nov 20, 2017

Oops. I just created a new ticket describing the same issue as jivimberg, but I'm using Windows. Would be great to have this sorted out, as this testing framework seems to have many advantages over the others.

@andrewleith

This comment has been minimized.

Copy link

commented Nov 21, 2017

I just tried troubleshooting to see why my setup works when others' do not. I removed my proxy settings from the VPN network settings and experienced the same behaviour as the others (no external sites would load). Once I added them back, still no external sites would load.

The only way I've gotten things to work is by running the tests once while not connected to the VPN, then they seem to work correctly afterwards when connected to the VPN (this is obviously not a solution for people trying to use Cypress from work). So I am concluding that this never properly worked for me over the VPN, I just thought it did.

I would very much like to see this issue get fixed so my team can try using Cypress on a few projects :)

Let me know what I can do to help.

@brian-mann

This comment has been minimized.

Copy link
Member

commented Nov 21, 2017

Since Cypress acts as a reverse proxy to the browser (which also ends up terminating traffic amongst other things), when it makes the external requests to 3rd party servers, it needs to respect the system proxy settings. That's why this is failing.

If Cypress proxied itself to the upstream proxy of the system, then all would work. This is likely a change that only needs to be made in a few places. The trick here is that we need a reproducible repo or the minimum steps to reproduce so we can write tests to ensure this is working.

Until someone does that, there are other things that will take priority over this feature.

@andrewleith

This comment has been minimized.

Copy link

commented Nov 21, 2017

Well isn't the requirement here for reproduction a VPN where a proxy is required to get out to the internet? It doesn't actually have anything to do with the repo itself, or am I missing something?

@brian-mann

This comment has been minimized.

Copy link
Member

commented Nov 21, 2017

That is true. However, you could likely put together a repo involving a transparent or reverse proxy that the traffic must tunnel through before hitting a regular http server.

The thing here is that I'm not sure if Cypress is supposed to read off the "corporate proxy" settings from the operating system itself - or if we need to expose configuration via cypress.json or environment variables that enables you to specify what the proxy is.

In other words - help us implement the exact steps needed to reproduce the failing environment so we can implement a solution to it. Even referencing other tools that do work would be helpful so we can look at how they solve this.

@andrewleith

This comment has been minimized.

Copy link

commented Nov 21, 2017

I can't see why Cypress wouldn't automatically use the system's proxy settings when it can. That would be my vote. Its also what most apps have done in my experience sitting behind our pointless corporate proxy.

As an aside, I have also tried adding environment variables (http_proxy, https_proxy) to the env key of the cypress.json file but still they were not honoured.

@brian-mann

This comment has been minimized.

Copy link
Member

commented Nov 21, 2017

Right - so we can definitely respect the http_proxy and https_proxy env variables - i just wasn't sure what Cypress would need to do to read off the system proxy settings (if these aren't set as env vars).

@brian-mann

This comment has been minimized.

Copy link
Member

commented Nov 21, 2017

Can you do an experiment - open node (any version) and check process.env to see if http_proxy is set without you explicitly setting it.

Or you could also just do print_env. What I'm trying to determine is whether these environment variables are automatically added by the system proxy. If they are not, then we'll need to come up with a way to read them all. I haven't looked but there's probably already modules that do this...

@andrewleith

This comment has been minimized.

Copy link

commented Nov 21, 2017

No, I cannot see either http_ or https_proxy in process.env.

@timothystone

This comment has been minimized.

Copy link

commented Nov 22, 2017

They are not added to node via the Mac OS X System Settings. They must be explicitly added to the environment in the shell, e.g., .zshenv. I'm not aware of node support for reading the system network preferences and exposing them as process variables, yet.

Update
I didn't have this gist handy—being on the Enterprise GitHub we run—to show how the standard team, using zsh, sets their proxy for using node

How to manage the proxy in ZSH...or one way to do so at the very least.

@andrewleith

This comment has been minimized.

Copy link

commented Nov 22, 2017

I would be happy with this working from the cypress.json config. Is that a possibility?

@brian-mann

This comment has been minimized.

Copy link
Member

commented Nov 22, 2017

Yes it looks like we can simply expose a new set of configuration in cypress.json for the proxy settings and also read them from process.env if they happen to be defined.

@g00fy-

This comment has been minimized.

Copy link

commented Nov 23, 2017

@brian-mann
please also enable setting strict-ssl, proxy and https-proxy in cypress.json as not all proxy have valid certificates

@brian-mann

This comment has been minimized.

Copy link
Member

commented Nov 23, 2017

We already turn off strict SSL handling in Cypress since Cypress itself is a proxy that issues invalid on the fly certificates.

Can anyone reference me another application that exposes the kinds of proxy configuration settings that is required here? I am still at a loss as to how many fields would need to be added to cypress.json

@g00fy-

This comment has been minimized.

Copy link

commented Nov 24, 2017

How about npm ?

https://docs.npmjs.com/misc/config#https-proxy
https://docs.npmjs.com/misc/config#proxy

It turns out that setting HTTPS_PROXY env in windows also works.

@timothystone

This comment has been minimized.

Copy link

commented Nov 26, 2017

@brian-mann see above ZSH proxy setter. At a minimum HTTP_PROXY, http_proxy, HTTPS_PROXY, and https_proxy.

In my corporate environment, all SSL connections are terminated at the proxy, so HTTPS and HTTP setting are identical. The UPPER and lower case versions are to cover a couple of edge cases where some programs don't recognize the conventions, e.g., npm apparently likes uses https-proxy (but looks for the underscore versions, as noted by @g00fy-).

@andrewleith

This comment has been minimized.

Copy link

commented Nov 27, 2017

After some experimentation, it appears cypress respects most of the environment proxy variables once they are set. If I set http_proxy before launching cypress, cypress respects the setting and sends traffic to the proxy first. The little gotcha here was that I also had to set the no_proxy variable to ensure that for localhost it did not attempt to use the proxy.

For some reason, resources over https were not sent through the proxy, even though I had also set the https_proxy variable. Perhaps I should be using some other variable? (I also tried HTTPS_PROXY)

@jivimberg Did you (or could you) try running cypress after setting both http_proxy and no_proxy and see if your setup can work as expected?

In summary, I think cypress should support at a minimum the following environment variables:
http_proxy
https_proxy
no_proxy

@jivimberg

This comment has been minimized.

Copy link

commented Nov 30, 2017

I tried with the 3 variables set and it's working!
Only thing that didn't work for me is with https requests, but maybe that's just my proxy settings?

@Baasie

This comment has been minimized.

Copy link

commented Dec 28, 2017

Looks like i am experiencing the same behaviour on a centos container where i can curl towards an https url but if i set this as my baseUrl it does not work. HTTPS_PROXY and https_proxy both are set.

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented Apr 4, 2018

@jedateach Hi, could you open a separate issue for this? This may certainly be proxy related, but the first I've seen for ensureUrl checks sending false checks.

@jedateach

This comment has been minimized.

Copy link

commented Apr 4, 2018

@jennifer-shehane Sure, added a new issue here: #1541

@brian-mann

This comment has been minimized.

Copy link
Member

commented Apr 24, 2018

@jedateach @vs yes, the reason that ensureUrl is failing is because those checks utilize a lower level net.connect as opposed to a real http request to see if there is an open TCP connection on the other side.

There is no nodejs support for proxying those, so we may have to switch to a regular http request to ensure the check.

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented Apr 26, 2018

Can ya'll try to set HTTP_PROXY and/or HTTPS_PROXY to your corporate proxy as system/shell environment variables? I detailed some of this fix here: #1469 (comment)

@egucciar

This comment has been minimized.

Copy link

commented Apr 26, 2018

Try the no_proxy setting too. That was the key for some of our devs

@rsmets

This comment has been minimized.

Copy link

commented Jun 14, 2018

@jedateach +1 same exact issue here. Upon removing from cypress.json baseUrl tests could finally talk out over the env var proxy settings.

@claritee

This comment has been minimized.

Copy link

commented Jul 1, 2018

This worked for me when I set HTTP_PROXY as an env var in my docker container and removed baseUrl

@jphchen

This comment has been minimized.

Copy link

commented Sep 14, 2018

e2e remote server testing behind corporate firewall is still an issue, this is very nice test framework but without proxy support it is difficult for this to go big ie. remote server serving static lib like google api from CDN

@rucciva

This comment has been minimized.

Copy link

commented Oct 15, 2018

i'm experiencing the same problem both using electron and chrome (running on osx), but only when accessing https website,

What weird is when running in docker container, the request to https successfully forwarded using proxy

setting HTTP_PROXY and/without HTTPS_PROXY yield the same result

@gtycherry

This comment has been minimized.

Copy link

commented Nov 29, 2018

Is this issue resolved? I am planning to use cypress as the testing tools in my project, but our application is seating in a corporate network.

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented Dec 4, 2018

@gtycherry This issue is still open, so has not been resolved. You may want to track the larger Corporate Proxy issue here: #1469

@cypress-bot

This comment has been minimized.

Copy link

commented Apr 1, 2019

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.

@cypress-bot

This comment has been minimized.

Copy link

commented May 17, 2019

Released in 3.3.0.

@santoshauz

This comment has been minimized.

Copy link

commented May 22, 2019

Resolved: Had a similar issue.

### Windows only
Environment variable gets set automatically with default proxy ( Company Proxy)
Delete the Variable and restart the PC (Optional)
Delete : http_proxy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.