Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set even more strict CSP header in redirect response #188

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Set even more strict CSP header in redirect response
  • Loading branch information
ljeda authored and ljeda committed Dec 17, 2024
commit e21ffada37716228c9da242bea6393c7e08c45de
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
@@ -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)
})

Loading