From c5c33a777332fa99c0210dff205cf9b69aa16234 Mon Sep 17 00:00:00 2001 From: Krishan Thisera Date: Mon, 23 Oct 2023 15:33:47 +1030 Subject: [PATCH] DO-1557: Send 'X-Prerender' along with the prerender requests --- packages/prerender-fargate/lib/prerender/server.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/prerender-fargate/lib/prerender/server.js b/packages/prerender-fargate/lib/prerender/server.js index 463ee56f..d7a41ef1 100644 --- a/packages/prerender-fargate/lib/prerender/server.js +++ b/packages/prerender-fargate/lib/prerender/server.js @@ -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'); @@ -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}});