Skip to content

Commit

Permalink
DO-1484: clean the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Park committed Sep 18, 2023
1 parent b57031b commit 2c2093c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/prerender-fargate/lib/prerender/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if (process.env.ENABLE_REDIRECT_CACHE.toLowerCase() === 'true'){
var he = require('he');
var s3 = new (require('aws-sdk')).S3({params:{Bucket: process.env.S3_BUCKET_NAME}});
server.use({
requestReceived: function(req, res, next) {
requestReceived: function(req, res, next) {
if(req.method !== 'GET' && req.method !== 'HEAD') {
console.log("skipping requestReceived from S3 Cache... ")
return next();
Expand All @@ -54,11 +54,10 @@ if (process.env.ENABLE_REDIRECT_CACHE.toLowerCase() === 'true'){
}

s3.getObject({
Key: key
Key: key
}, function (err, result) {

if (!err && result) {
console.log(result.Metadata);
console.log("Found cached object: " + key);
if (result.Metadata.location){
res.setHeader('Location', result.Metadata.location);
Expand All @@ -72,7 +71,6 @@ if (process.env.ENABLE_REDIRECT_CACHE.toLowerCase() === 'true'){
});
},
// The pageLoaded function is a modified version of https://github.com/prerender/prerender/blob/478fa6d0a5196ea29c88c69e64e72eb5507b6d2c/lib/plugins/httpHeaders.js

pageLoaded: function(req, res, next) {
const statusCodesToCache = ['200', '301', '302'];
let metaTagStatusCode = 200;
Expand Down

0 comments on commit 2c2093c

Please sign in to comment.