Skip to content

Commit

Permalink
add x-prerender-requestid header to indicate that the response is fro…
Browse files Browse the repository at this point in the history
…m prerender
  • Loading branch information
Chris Park committed Jul 31, 2023
1 parent a4b1c16 commit 613f814
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/prerender-fargate/lib/prerender/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ server.use({
let auth = req.headers['x-prerender-token'];
if (!auth) return res.send(401);

// check credentials exist
if (!auth) return res.send(401);

// compare credentials in header to list of allowed credentials
const tokenAllowList = process.env.TOKEN_LIST.toString().split(',');

Expand All @@ -28,7 +25,12 @@ server.use({
}
if (!authenticated) return res.send(401);

next();
return next();
},
// Append a custom header to indicate the response is from Prerender
beforeSend: function(req, res, next) {
res.setHeader('x-prerender-requestid', crypto.randomUUID());
return next();
}
});

Expand Down

0 comments on commit 613f814

Please sign in to comment.