Skip to content

Commit

Permalink
Changed helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
cindywgg committed Jan 24, 2025
1 parent 9427341 commit 1bf7d5a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Binary file modified dump.rdb
Binary file not shown.
24 changes: 11 additions & 13 deletions src/middleware/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ module.exports = function (middleware) {
'Access-Control-Allow-Headers': encodeURI(meta.config['access-control-allow-headers'] || ''),
};

setCspAndFrame(headers, meta.config);
if (meta.config['csp-frame-ancestors']) {
headers['Content-Security-Policy'] = `frame-ancestors ${meta.config['csp-frame-ancestors']}`;
if (meta.config['csp-frame-ancestors'] === '\'none\'') {
headers['X-Frame-Options'] = 'DENY';
}
} else {
headers['Content-Security-Policy'] = 'frame-ancestors \'self\'';
headers['X-Frame-Options'] = 'SAMEORIGIN';
}

console.log('cindy wang');

setAccessControlAllow(headers, meta.config, req);

Expand Down Expand Up @@ -79,18 +89,6 @@ module.exports = function (middleware) {
}
};

function setCspAndFrame(headers, config) {
if (config['csp-frame-ancestors']) {
headers['Content-Security-Policy'] = `frame-ancestors ${config['csp-frame-ancestors']}`;
if (config['csp-frame-ancestors'] === '\'none\'') {
headers['X-Frame-Options'] = 'DENY';
}
} else {
headers['Content-Security-Policy'] = 'frame-ancestors \'self\'';
headers['X-Frame-Options'] = 'SAMEORIGIN';
}
}

function setAccessControlAllow(headers, config, req) {
if (config['access-control-allow-origin']) {
let origins = config['access-control-allow-origin'].split(',');
Expand Down

0 comments on commit 1bf7d5a

Please sign in to comment.