Created
May 20, 2022 12:12
-
-
Save ArthurKnoep/263b3c6514bb01bb1efb07048990c5ff to your computer and use it in GitHub Desktop.
Managing CORS, CSP, X-Frame-Options, and other Security HTTP Headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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