remove unnecessary HTTP headers

This commit is contained in:
2020-06-09 12:59:43 -04:00
parent 60f7a85da4
commit f810c0d393
+4 -18
View File
@@ -32,28 +32,14 @@ async function handleEvent(event) {
} }
} }
const headers = {
'X-XSS-Protection': '1; mode=block',
'X-Frame-Options': 'DENY',
'X-Content-Type-Options': 'nosniff',
'x-y2k-backend': 'v5',
'x-y2k-debug': DEBUG,
}
try { try {
// make debugging easier (see top of this file)
if (DEBUG) options.cacheControl.bypassCache = true if (DEBUG) options.cacheControl.bypassCache = true
// asset was found, the good stuff goes here // asset was found
let asset = await getAssetFromKV(event, options) return await getAssetFromKV(event, options)
// set various security headers above
Object.keys(headers).forEach((name) => {
asset.headers.set(name, headers[name])
})
return asset
} catch (e) { } catch (e) {
// if an error is thrown try to serve the asset at 404.html // if a 404 error is thrown try to serve the asset at 404.html
if (!DEBUG) { if (!DEBUG) {
try { try {
let notFoundResponse = await getAssetFromKV(event, { let notFoundResponse = await getAssetFromKV(event, {