mirror of
https://github.com/cypress-io/cypress.git
synced 2026-03-10 19:39:10 -05:00
fix: Ensure response headers are set for extra target network requests (#28322)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user