From 70f97cbb43538796c7db463f3643e761bb221c76 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 17 Nov 2021 17:13:59 -0800 Subject: [PATCH] fix: Only capture 404 --- server/routes/index.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/server/routes/index.js b/server/routes/index.js index 4245b10d08..bcdb9f9c28 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -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; } }); }