workers-site: fix 404 fallback [staging]

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2021-01-11 02:16:01 +05:30
parent e76545b8dc
commit 4a138b4a1e
1 changed files with 3 additions and 0 deletions

View File

@ -15,6 +15,9 @@ async function getPageFromKV(event: FetchEvent): Promise<Response> {
const options = {}
try {
const page = await getAssetFromKV(event, options)
if (page === null) {
throw new Error("No page found, short-circuit to 404 page");
}
const response = new Response(page.body, page)
response.headers.set('X-XSS-Protection', '1; mode=block')
response.headers.set('X-Content-Type-Options', 'nosniff')