Skip to content

Commit

Permalink
Set even more strict CSP header in redirect response
Browse files Browse the repository at this point in the history
  • Loading branch information
ljeda authored and ljeda committed Dec 17, 2024
1 parent e2bf828 commit e21ffad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function createRedirectDirectoryListener () {
res.statusCode = 301
res.setHeader('Content-Type', 'text/html; charset=UTF-8')
res.setHeader('Content-Length', Buffer.byteLength(doc))
res.setHeader('Content-Security-Policy', "default-src 'none'")
res.setHeader('Content-Security-Policy', "default-src 'none'; frame-ancestors 'none'; form-action 'none'")
res.setHeader('X-Content-Type-Options', 'nosniff')
res.setHeader('Location', loc)
res.end(doc)
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ describe('serveStatic()', function () {
it('should respond with default Content-Security-Policy', function (done) {
request(server)
.get('/users')
.expect('Content-Security-Policy', "default-src 'none'")
.expect('Content-Security-Policy', "default-src 'none'; frame-ancestors 'none'; form-action 'none'")
.expect(301, done)
})

Expand Down

0 comments on commit e21ffad

Please sign in to comment.