Skip to content

Commit

Permalink
Merge pull request #1061 from aligent/feature/DO-1285_add_custom_resp…
Browse files Browse the repository at this point in the history
…onse_header

Feature/do 1285 add custom response header
  • Loading branch information
TheOrangePuff authored Jul 31, 2023
2 parents a4b1c16 + 613f814 commit b86383b
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 b86383b

Please sign in to comment.