fix: Only capture 404

This commit is contained in:
Tom Moor committed 2021-11-17 17:42:28 -08:00
1 parent b664b03b45
commit 70f97cbb43
1 file changed
+10 -5
+10 -5
View File
@@ -104,11 +104,16 @@ if (true || process.env.NODE_ENV === "production") {
res.setHeader("Cache-Control", `max-age=${365 * 24 * 60 * 60}`);
},
});
} catch {
// Serve a bad request instead of not found if the file doesn't exist
// This prevents CDN's from caching the response, allowing them to continue
// serving old file versions
ctx.status = 400;
} catch (err) {
if (err.status === 404) {
// Serve a bad request instead of not found if the file doesn't exist
// This prevents CDN's from caching the response, allowing them to continue
// serving old file versions
ctx.status = 400;
return;
}
throw err;
}
});
}