Skip to content

Commit

Permalink
fix: Ensure response headers are set for extra target network requests (
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbreiding committed Nov 13, 2023
1 parent 8274f5d commit 9d9bf25
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ _Released 11/21/2023 (PENDING)_

**Bugfixes:**

- Fixed an issue where pages opened in a new tab were missing response headers, causing them not to load properly. Fixes [#28293](https://github.com/cypress-io/cypress/issues/28293) and [#28303](https://github.com/cypress-io/cypress/issues/28303).
- We now pass a flag to Chromium browsers to disable default component extensions. This is a common flag passed during browser automation. Fixed in [#28294](https://github.com/cypress-io/cypress/pull/28294).

## 13.5.0
Expand Down
4 changes: 4 additions & 0 deletions packages/proxy/lib/http/response-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ const FilterNonProxiedResponse: ResponseMiddleware = function () {
if (this.req.isFromExtraTarget) {
this.debug('response for [%s %s] is from extra target', this.req.method, this.req.proxiedUrl)

// this is normally done in the OmitProblematicHeaders middleware, but we
// don't want to omit any headers in this case
this.res.set(this.incomingRes.headers)

this.onlyRunMiddleware([
'AttachPlainTextStreamFn',
'PatchExpressSetHeader',
Expand Down
8 changes: 7 additions & 1 deletion packages/proxy/test/unit/http/response-middleware.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,28 @@ describe('http/response-middleware', function () {
describe('FilterNonProxiedResponse', () => {
const { FilterNonProxiedResponse } = ResponseMiddleware
let ctx
let headers

beforeEach(() => {
headers = { 'header-name': 'header-value' }
ctx = {
onlyRunMiddleware: sinon.stub(),
incomingRes: { headers },
req: {},
res: {
set: sinon.stub(),
off: (event, listener) => {},
},
}
})

it('runs minimal subsequent middleware if request is from an extra target', () => {
it('sets headers on response and runs minimal subsequent middleware if request is from an extra target', () => {
ctx.req.isFromExtraTarget = true

return testMiddleware([FilterNonProxiedResponse], ctx)
.then(() => {
expect(ctx.res.set).to.be.calledWith(headers)

expect(ctx.onlyRunMiddleware).to.be.calledWith([
'AttachPlainTextStreamFn',
'PatchExpressSetHeader',
Expand Down

5 comments on commit 9d9bf25

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9d9bf25 Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.5.1/linux-arm64/develop-9d9bf25977cfccd53202b1e0fa93e45c8fbd58e4/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9d9bf25 Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.5.1/linux-x64/develop-9d9bf25977cfccd53202b1e0fa93e45c8fbd58e4/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9d9bf25 Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.5.1/darwin-x64/develop-9d9bf25977cfccd53202b1e0fa93e45c8fbd58e4/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9d9bf25 Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.5.1/darwin-arm64/develop-9d9bf25977cfccd53202b1e0fa93e45c8fbd58e4/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9d9bf25 Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.5.1/win32-x64/develop-9d9bf25977cfccd53202b1e0fa93e45c8fbd58e4/cypress.tgz

Please sign in to comment.