diff --git a/packages/prerender-fargate/lib/prerender/server.js b/packages/prerender-fargate/lib/prerender/server.js index 9f43674e..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,9 @@ server.use({ headerMatch = headerMatchRegex.exec(head) } - if (['301', '302'].includes(req.prerender.statusCode )) { - req.prerender.content = `This page has moved, redirecting to ${s3Metadata.location}...`; + 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}...`; } if ( statusCodesToCache.includes(req.prerender.statusCode.toString()) ){ diff --git a/packages/prerender-fargate/package.json b/packages/prerender-fargate/package.json index 4e8b04c1..2be027e8 100644 --- a/packages/prerender-fargate/package.json +++ b/packages/prerender-fargate/package.json @@ -1,6 +1,6 @@ { "name": "@aligent/cdk-prerender-fargate", - "version": "2.5.0", + "version": "2.5.1", "description": "A construct to host Prerender in Fargate", "main": "index.js", "scripts": {