Skip to content

Commit

Permalink
Merge pull request #1144 from aligent/feature/DO-1557_pass_prerender_…
Browse files Browse the repository at this point in the history
…request_header

DO-1557: Send 'X-Prerender' HTTP header along with the prerender requests
  • Loading branch information
krishanthisera authored Oct 24, 2023
2 parents bc8b3e7 + c5c33a7 commit 7e055aa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/prerender-fargate/lib/prerender/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/**
* This file defines a Prerender server that uses AWS S3 cache to cache prerendered pages.
* It also includes middleware to handle authentication, append a custom header to indicate the response is from Prerender,
* and remove script tags from the prerendered content.
* @requires prerender
* @requires crypto
* @requires prerender-aws-s3-cache
* @requires he
* @requires aws-sdk
* @requires fs
*/
'use strict';

const prerender = require('prerender');
Expand Down Expand Up @@ -44,6 +55,9 @@ server.use({

server.use(prerender.blacklist());

// Send 'X-Prerender': '1'
server.use(prerender.sendPrerenderHeader());

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}});
Expand Down

0 comments on commit 7e055aa

Please sign in to comment.