Skip to content

Commit

Permalink
fix: process authentication first
Browse files Browse the repository at this point in the history
By processing authentication first, we fix the issue where the s3cache
would kick on first on `/`. This would result in showing the contents of
the S3 bucket rather than a 401.
  • Loading branch information
TheOrangePuff committed May 22, 2023
1 parent 5030391 commit 77249fc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/prerender-fargate/lib/prerender/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ const server = prerender({
chromeLocation: '/usr/bin/chromium-browser'
});

server.use(prerender.blacklist());
server.use(prerender.httpHeaders());
server.use(prerender.removeScriptTags());
server.use(s3Cache);

server.use({
requestReceived: (req, res, next) => {
let auth = req.headers['x-prerender-token'];
Expand All @@ -33,8 +28,13 @@ server.use({
}
if (!authenticated) return res.send(401);

return next();
next();
}
});

server.use(prerender.blacklist());
server.use(prerender.httpHeaders());
server.use(prerender.removeScriptTags());
server.use(s3Cache);

server.start();

0 comments on commit 77249fc

Please sign in to comment.