Files
cypress/patches/node-fetch+2.7.0.patch
Björn Weström 66dac2341c fix: #29171 set correct host header with fetch (#29452)
* Patch node-fetch to set defaultPort based on protocol

* unit test that proper host headers are sent with fetch

* changelog

* make patch more robust

---------

Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
2024-05-07 10:04:48 -04:00

16 lines
630 B
Diff

diff --git a/node_modules/node-fetch/lib/index.js b/node_modules/node-fetch/lib/index.js
index 567ff5d..c7e2bd9 100644
--- a/node_modules/node-fetch/lib/index.js
+++ b/node_modules/node-fetch/lib/index.js
@@ -1449,7 +1449,9 @@ function fetch(url, opts) {
const request = new Request(url, opts);
const options = getNodeRequestOptions(request);
- const send = (options.protocol === 'https:' ? https : http).request;
+ const isHttps = options.protocol === 'https:';
+ options.defaultPort = (isHttps ? 443 : 80);
+ const send = (isHttps ? https : http).request;
const signal = request.signal;
let response = null;