Skip to content

Commit b8e0982

Browse files
Merge branch 'develop' into feat/cy-prompt
2 parents f20d548 + 99950b7 commit b8e0982

File tree

4 files changed

+54
-3
lines changed

4 files changed

+54
-3
lines changed

.circleci/workflows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 2.1
22

3-
chrome-stable-version: &chrome-stable-version "138.0.7204.92"
3+
chrome-stable-version: &chrome-stable-version "138.0.7204.100"
44
chrome-beta-version: &chrome-beta-version "139.0.7258.5"
55
firefox-stable-version: &firefox-stable-version "137.0"
66

cli/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ _Released 7/15/2025 (PENDING)_
66
**Bugfixes:**
77

88
- Fixed a regression introduced in [`14.5.0`](https://docs.cypress.io/guides/references/changelog#14-5-0) where the Stop button would not immediately stop the spec timer. Addresses [#31920](https://github.com/cypress-io/cypress/issues/31920).
9+
- Fixed an issue with the `CloudRequest` where it used the wrong port for `https` requests. Addressed in [#31992](https://github.com/cypress-io/cypress/pull/31992).
910

1011
## 14.5.1
1112

packages/network/lib/agent.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export const createProxySock = (opts: CreateProxySockOpts, cb: CreateProxySockCb
126126

127127
export const isRequestHttps = (options: http.RequestOptions) => {
128128
// WSS connections will not have an href, but you can tell protocol from the defaultAgent
129-
return _.get(options, '_defaultAgent.protocol') === 'https:' || (options.href || '').slice(0, 6) === 'https:'
129+
return _.get(options, '_defaultAgent.protocol') === 'https:' || options.protocol === 'https:' || (options.href || '').slice(0, 6) === 'https:'
130130
}
131131

132132
export const isResponseStatusCode200 = (head: string) => {
@@ -226,6 +226,11 @@ export class CombinedAgent {
226226

227227
const isHttps = isRequestHttps(options)
228228

229+
// Ensure that HTTPS requests are using 443
230+
if (isHttps && options.port === 80) {
231+
options.port = 443
232+
}
233+
229234
if (!options.href) {
230235
// options.path can contain query parameters, which url.format will not-so-kindly urlencode for us...
231236
// so just append it to the resultant URL string

packages/server/test/unit/cloud/api/cloud_request_spec.ts

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ import agent from '@packages/network/lib/agent'
66
import axios, { CreateAxiosDefaults, AxiosInstance } from 'axios'
77
import debugLib from 'debug'
88
import stripAnsi from 'strip-ansi'
9-
import { createCloudRequest } from '../../../../lib/cloud/api/cloud_request'
9+
import { CloudRequest, createCloudRequest } from '../../../../lib/cloud/api/cloud_request'
1010
import cloudApi from '../../../../lib/cloud/api'
1111
import app_config from '../../../../config/app.json'
1212
import os from 'os'
1313
import pkg from '@packages/root'
1414
import { transformError } from '../../../../lib/cloud/api/axios_middleware/transform_error'
1515
import { DestroyableProxy, fakeServer, fakeProxy } from './utils/fake_proxy_server'
1616
import dedent from 'dedent'
17+
import { PassThrough } from 'stream'
18+
import fetch from 'cross-fetch'
19+
import nock from 'nock'
1720

1821
chai.use(sinonChai)
1922

@@ -444,6 +447,48 @@ describe('CloudRequest', () => {
444447
})
445448
})
446449

450+
describe('https requests', () => {
451+
it('handles https requests properly', async () => {
452+
nock.restore()
453+
454+
// @ts-ignore
455+
const addRequestSpy = sinon.stub(agent.httpsAgent, 'addRequest').callsFake((req, options) => {
456+
// fake IncomingMessage
457+
const res = new PassThrough() as any
458+
459+
res.statusCode = 200
460+
res.headers = {
461+
'content-type': 'application/json',
462+
}
463+
464+
process.nextTick(() => {
465+
req.emit('response', res)
466+
res.write(JSON.stringify({ ok: options.port === 443 && options.protocol === 'https:' }))
467+
res.end()
468+
})
469+
})
470+
471+
const result1 = await CloudRequest.post('https://cloud.cypress.io/ping', {})
472+
473+
expect(result1.data).to.eql({ ok: true })
474+
475+
const result2 = await createCloudRequest({ baseURL: 'https://api.cypress.io' }).post('/ping', {})
476+
477+
expect(result2.data).to.eql({ ok: true })
478+
479+
const result3 = await fetch('https://cloud.cypress.io/ping', {
480+
method: 'POST',
481+
body: '{}',
482+
// @ts-expect-error - this is supported
483+
agent,
484+
})
485+
486+
expect(await result3.json()).to.eql({ ok: true })
487+
488+
expect(addRequestSpy).to.have.been.calledThrice
489+
})
490+
})
491+
447492
;[undefined, 'development', 'test', 'staging', 'production'].forEach((env) => {
448493
describe(`base url for CYPRESS_CONFIG_ENV "${env}"`, () => {
449494
let prevEnv

0 commit comments

Comments
 (0)