Skip to content

Commit

Permalink
fix(proxy): omit CSP report only header
Browse files Browse the repository at this point in the history
Since Cypress omits the blocking CSP header, it should also omit the
report-only CSP header. This fixes a lot of `unsafe-inline` script-src
warnings that I have seen when running cypress.
  • Loading branch information
sdemjanenko committed Jul 9, 2020
1 parent 4b4628e commit 94fc5ed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/proxy/lib/http/response-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ const OmitProblematicHeaders: ResponseMiddleware = function () {
'x-frame-options',
'content-length',
'content-security-policy',
'content-security-policy-report-only',
'connection',
])

Expand Down
21 changes: 21 additions & 0 deletions packages/server/test/integration/http_requests_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2072,6 +2072,27 @@ describe('Routes', () => {
})
})

it('omits content-security-policy-report-only', function () {
nock(this.server._remoteOrigin)
.get('/bar')
.reply(200, 'OK', {
'Content-Type': 'text/html',
'content-security-policy-report-only': 'foobar;',
})

return this.rp({
url: 'http://localhost:8080/bar',
headers: {
'Cookie': '__cypress.initial=false',
},
})
.then((res) => {
expect(res.statusCode).to.eq(200)

expect(res.headers).not.to.have.property('content-security-policy-report-only')
})
})

it('omits document-domain from Feature-Policy header', function () {
nock(this.server._remoteOrigin)
.get('/bar')
Expand Down

0 comments on commit 94fc5ed

Please sign in to comment.