Skip to content

Instantly share code, notes, and snippets.

@ArthurKnoep
Created May 20, 2022 12:12
Show Gist options
  • Save ArthurKnoep/263b3c6514bb01bb1efb07048990c5ff to your computer and use it in GitHub Desktop.
Save ArthurKnoep/263b3c6514bb01bb1efb07048990c5ff to your computer and use it in GitHub Desktop.
Managing CORS, CSP, X-Frame-Options, and other Security HTTP Headers
function handler(event) {
var response = event.response;
var headers = response.headers;
headers['strict-transport-security'] = { value: 'max-age=63072000; includeSubdomains; preload'};
headers['content-security-policy'] = { value: "default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self'; object-src 'none'"};
headers['x-content-type-options'] = { value: 'nosniff'};
headers['x-frame-options'] = {value: 'DENY'};
headers['x-xss-protection'] = {value: '1; mode=block'};
headers['access-control-allow-origin'] = {value: "*"};
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment