remove unnecessary HTTP headers
This commit is contained in:
+4
-18
@@ -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, {
|
||||||
|
|||||||
Reference in New Issue
Block a user