Skip to content

Commit

Permalink
Also include 308 Permanent Redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
jswift committed Jun 14, 2024
1 parent 12931a6 commit 3773941
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/prerender-fargate/lib/prerender/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 <a href="${s3Metadata.location}">${s3Metadata.location}</a>...`;
}

Expand Down

0 comments on commit 3773941

Please sign in to comment.