Skip to content

Commit

Permalink
Merge pull request #237 from eevans/csp-docs
Browse files Browse the repository at this point in the history
content-security-policy headers breakage
  • Loading branch information
gwicke committed Apr 25, 2015
2 parents 670f63a + 54d079f commit 955bc62
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/server.js
Expand Up @@ -43,8 +43,10 @@ function handleResponse (opts, req, resp, response) {

if (!/^application\/json/.test(rh['content-type'])) {
rh['X-XSS-Protection'] = '1; mode=block';
rh['Content-Security-Policy'] =
"default-src 'none'; media-src *; img-src *; style-src *; frame-ancestors 'self'";
if (!rh['Content-Security-Policy']) {
rh['Content-Security-Policy'] =
"default-src 'none'; media-src *; img-src *; style-src *; frame-ancestors 'self'";
}
// For IE 10 & 11
rh['X-Content-Security-Policy'] = rh['Content-Security-Policy'];
// For Chrome <= v25 (seems to be <1% traffic; should we still
Expand Down
1 change: 1 addition & 0 deletions lib/swaggerUI.js
Expand Up @@ -37,6 +37,7 @@ function staticServe (restbase, req) {
status: 200,
headers: {
'content-type': contentType,
'Content-Security-Policy': "default-src 'none'; script-src 'self' 'unsafe-inline'; connect-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self'; font-src 'self';"
},
body: body
});
Expand Down

0 comments on commit 955bc62

Please sign in to comment.