From 295de2e979dfe59df758d33187f7879861daa476 Mon Sep 17 00:00:00 2001 From: brannon Date: Thu, 19 May 2022 15:33:09 -0600 Subject: [PATCH] Change cache test env vars to read from HTTP headers instead. --- middleware/fastly-cache-test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/middleware/fastly-cache-test.js b/middleware/fastly-cache-test.js index 8f460aa613..0ba8b28c91 100644 --- a/middleware/fastly-cache-test.js +++ b/middleware/fastly-cache-test.js @@ -8,14 +8,14 @@ // NOTE: This middleware is intended to be removed once testing is complete! // export default function fastlyCacheTest(req, res, next) { - // If CACHE_TEST_ERROR is set, simulate the site being down (regardless of URL) - if (process.env.CACHE_TEST_ERROR) { - res.status(parseInt(process.env.CACHE_TEST_ERROR)).end() + // If X-CacheTest-Error is set, simulate the site being down (regardless of URL) + if (req.get('X-CacheTest-Error')) { + res.status(parseInt(req.get('X-CacheTest-Error'))).end() return } - const staleIfErrorParam = process.env.CACHE_TEST_STALE_IF_ERROR ?? '300' - const staleWhileRevalidateParam = process.env.CACHE_TEST_STALE_WHILE_REVALIDATE ?? '60' + const staleIfErrorParam = req.get('X-CacheTest-StaleIfError') ?? '300' + const staleWhileRevalidateParam = req.get('X-CacheTest-StaleWhileRevalidate') ?? '60' const path = req.params[0]