Using Cypress behind a corporate proxy / VPN - oh no!

tugkankibar

H. Tuğkan Kibar

Posted on May 26, 2021

Using Cypress behind a corporate proxy / VPN - oh no!

Working behind a corporate VPN / proxy is a situation most of us (especially when working in large corporations) have to face day to day. If so, and if you are using a tool such as ZScaler, you might end up getting a dreaded "Error: unable to get local issuer certificate" error when trying to install Cypress for the first time.

Surely you could disable the VPN, and all would be well - mainly due to Cypress caching the version it downloads.

However - to fix this issue you could also go for the following route of including the binary into your repo (or a mirror of course).

To do so - here is what I've done;

  1. Download the binary from Cypress - most likely your CLI will already show the URL for the failed download step.
  2. (Skip this step if you will mirror Cypress) Create a folder for your binaries, I've went with making a binaries folder, at the project root and creating a cypress folder there which includes the downloaded file as version.zip, in this case "6.9.1.zip". (You can use a different folder / naming obviously).
  3. Create / edit the .npmrc file at the project root level.
  4. Depending on your situation add one of the following lines;

    1. If you will include the binary in your own repo like I've noted: CYPRESS_INSTALL_BINARY=../../binaries/cypress/6.9.1.zip
    2. If you will mirror the cypress and keep the same layout: CYPRESS_DOWNLOAD_MIRROR=https://example.com/
  5. Check if it works by running yarn or npm install. Remember - if it worked even once; you might have stuff still in cache. To make sure that is not the case, you can run rm -rf $(npx cypress cache path) which will clear out your cache location.

Hope it helps - happy hacking!

💖 💪 🙅 🚩
tugkankibar
H. Tuğkan Kibar

Posted on May 26, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related