fix: Ensure response headers are set for extra target network requests (#28322)

This commit is contained in:
Chris Breiding
2023-11-13 17:51:51 -05:00
committed by GitHub
parent 8274f5ddb2
commit 9d9bf25977
3 changed files with 12 additions and 1 deletions

View File

@@ -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

View File

@@ -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',

View File

@@ -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',