DEV Community

Cover image for Cypress proxy setup: HTTP_PROXY, auth, NO_PROXY and geo-QA
proxymint
proxymint

Posted on Originally published at proxymint.com

Cypress proxy setup: HTTP_PROXY, auth, NO_PROXY and geo-QA

Originally published on proxymint.

Set a Cypress proxy with HTTP_PROXY, pass credentials, keep localhost off it with NO_PROXY, fix 407 and SOCKS errors, and run geo-QA one exit per run.

TL;DR

  • Just export HTTP_PROXY in the shell that starts Cypress. It's an operating system variable, so putting a proxy under Cypress env config does nothing, and HTTPS quietly falls back to the same value unless you set HTTPS_PROXY.
  • In Electron, Firefox and WebKit the browser never talks to the proxy. Cypress points it at its own local proxy and forwards upstream from Node. Since Cypress 16, Chrome, Chromium and Edge get HTTP_PROXY handed to them directly, and that changes how passwords work.
  • On the Node path, credentials go inside the URL, percent-encoded. Cypress sends them as Basic auth; a raw #, / or ? can break parsing. Native-browser 407 handling in Cypress 16 is untested here, so do not assume the same auth behaviour.
  • SOCKS and PAC files don't work. You get 'Unsupported proxy protocol: socks5:' in the log, and the fix is an HTTP endpoint or a local HTTP bridge in front of the SOCKS proxy.
  • For geo-QA, think in runs, not tests. The proxy is read once at startup, so each country gets its own run with a sticky exit and a first spec that asserts where the traffic really leaves from.

Key takeaways

  • Check what Cypress actually picked up before changing anything. Open Settings, then Proxy Settings, or run with DEBUG=cypress:server:util:proxy, since cypress info stopped printing proxy variables in 16.0.0.
  • Watch for a lowercase http_proxy left on the runner. It beats the uppercase one, and it's the usual reason CI ignores the value you set.
  • Fix install and run separately. The binary download ignores the Windows registry and NODE_EXTRA_CA_CERTS, so a TLS-intercepting network needs cafile in .npmrc or CYPRESS_DOWNLOAD_MIRROR.
  • Set timezone and language yourself on geo runs. The proxy only moves the IP, so pass TZ and a --lang argument for the run and assert both, because a mismatch fails silently.
  • Stub heavy assets when the exit is billed per GB. A cy.intercept rule that answers images, video and fonts with a 204 keeps a long suite's traffic down without touching the specs that matter.

Read the full guide on proxymint, with the commands, tables and sources.

Top comments (0)