From 3773941125109a352c7e88a753723b1ed40ca533 Mon Sep 17 00:00:00 2001 From: Jarrod Swift Date: Fri, 14 Jun 2024 14:03:44 +0930 Subject: [PATCH] Also include 308 Permanent Redirect --- packages/prerender-fargate/lib/prerender/server.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/prerender-fargate/lib/prerender/server.js b/packages/prerender-fargate/lib/prerender/server.js index b54bc8e6..63e09a01 100644 --- a/packages/prerender-fargate/lib/prerender/server.js +++ b/packages/prerender-fargate/lib/prerender/server.js @@ -160,7 +160,7 @@ server.use(prerender.removeScriptTags()); server.use({ pageLoaded: function(req, res, next) { - const statusCodesToCache = process.env.ENABLE_REDIRECT_CACHE.toLowerCase() === 'true' ? ['200', '301', '302'] : ['200']; + const statusCodesToCache = process.env.ENABLE_REDIRECT_CACHE.toLowerCase() === 'true' ? ['200', '301', '302', '308'] : ['200']; var s3Metadata = {} const cacheObject = function (err, result) { if (!err && result) { @@ -200,8 +200,8 @@ server.use({ headerMatch = headerMatchRegex.exec(head) } - if (['301', '302', '307'].includes(req.prerender.statusCode )) { - const permanentlyOrTemporarily = req.prerender.statusCode === '301' ? 'permanently': 'temporarily'; + if (['301', '302', '307', '308'].includes(req.prerender.statusCode)) { + const permanentlyOrTemporarily = ['301', '308'].includes(req.prerender.statusCode) ? 'permanently': 'temporarily'; req.prerender.content = `This page has ${permanentlyOrTemporarily} moved, redirecting to ${s3Metadata.location}...`; }