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

fix: #29171 set correct host header with fetch #29452

Merged
merged 5 commits into from
May 7, 2024

Conversation

bjowes
Copy link
Contributor

@bjowes bjowes commented May 1, 2024

Additional details

Use of node-fetch, in particular during launch of the Cypress UI when started with cypress open, did not pass the correct host header to the proxy when accessing HTTPS sites. This affected many corporate proxies that perform HTTPS decryption, resulting in that the requests did not reach their target servers. In addition it caused the launcher to hang.

The implementation is a patch of the node-patch library to set the defaultPort option based on the protocol of the URL. If a specific port is set in the URL, this will still override the defaultPort.

Steps to test

Place cypress behind a proxy that performs HTTPS decryption and launch cypress with npx cypress open.

One such proxy is the ntlm-proxy part of https://github.com/bjowes/cypress-ntlm-auth :

  1. Open a terminal, create a testing folder, initiate npm and install cypress-ntlm-auth. Run npx ntlm-proxy. Note the ports used for configApiUrl and ntlmProxyUrl.
  2. Open another terminal, configure ntlm-proxy with (make sure to replace xxx with the port from configApiUrl)
    curl -d '{ "ntlmHosts": ["download.cypress.io", "registry.npmjs.org", "on.cypress.io"], "username": "dummy", "password": "dummy", "ntlmVersion": 2 }' -H 'Content-Type: application/json' http://127.0.0.1:xxx/ntlm-config
    The call should return OK.
  3. Start cypress with the proxy: HTTP_PROXY=http://127.0.0.1:yyy npx cypress open, make sure to replace yyy with the port from ntlmProxyUrl. The launcher will stall and requests to download.cypress.io, registry.npmjs.org and on.cypress.io will fail.

Repeat step 3 with this PR applied, then the launcher shall work as intended. To test the proxy without HTTPS decryption, simply skip step 2.

How has the user experience changed?

The launcher now works as expected behind proxies that perform HTTPS decryption - for other users no change.

PR Tasks

  • Have tests been added/updated?
  • Has a PR for user-facing changes been opened in cypress-documentation? NA - No documentation needs updating
  • Have API changes been updated in the type definitions? NA - No APIs have been changed

@cypress-app-bot
Copy link
Collaborator

@jennifer-shehane jennifer-shehane merged commit 66dac23 into cypress-io:develop May 7, 2024
67 checks passed
@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 8, 2024

Released in 13.9.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v13.9.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators May 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cypress open hangs for a minute or two before loading
5 participants