From b7001d7541c6b72758d2b147664e408c035e4a46 Mon Sep 17 00:00:00 2001 From: Jarrod Swift Date: Wed, 12 Jun 2024 15:37:26 +0930 Subject: [PATCH 1/4] Package version is incorrect, current version is 2.4.0 --- packages/prerender-fargate/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/prerender-fargate/package.json b/packages/prerender-fargate/package.json index 3cb9fcb1..37ebfe65 100644 --- a/packages/prerender-fargate/package.json +++ b/packages/prerender-fargate/package.json @@ -1,6 +1,6 @@ { "name": "@aligent/cdk-prerender-fargate", - "version": "2.3.8", + "version": "2.4.0", "description": "A construct to host Prerender in Fargate", "main": "index.js", "scripts": { From ab7d158dfdc071f498f3d9dc6b8fcf286c434617 Mon Sep 17 00:00:00 2001 From: Jarrod Swift Date: Wed, 12 Jun 2024 15:39:03 +0930 Subject: [PATCH 2/4] If response is a redirect, don't respond with all the page content, just a text note --- packages/prerender-fargate/lib/prerender/server.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/prerender-fargate/lib/prerender/server.js b/packages/prerender-fargate/lib/prerender/server.js index f521610e..9f43674e 100644 --- a/packages/prerender-fargate/lib/prerender/server.js +++ b/packages/prerender-fargate/lib/prerender/server.js @@ -200,6 +200,10 @@ server.use({ headerMatch = headerMatchRegex.exec(head) } + if (['301', '302'].includes(req.prerender.statusCode )) { + req.prerender.content = `This page has moved, redirecting to ${s3Metadata.location}...`; + } + if ( statusCodesToCache.includes(req.prerender.statusCode.toString()) ){ s3Metadata.httpreturncode = req.prerender.statusCode.toString() From b66f740872a01593be520b6d5d831f92eaf8956e Mon Sep 17 00:00:00 2001 From: Jarrod Swift Date: Thu, 13 Jun 2024 09:22:01 +0930 Subject: [PATCH 3/4] Add brief note about running the prerender container locally --- packages/prerender-fargate/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/prerender-fargate/README.md b/packages/prerender-fargate/README.md index 7f3d994d..0c045559 100644 --- a/packages/prerender-fargate/README.md +++ b/packages/prerender-fargate/README.md @@ -146,6 +146,19 @@ export class RagPrerenderStackStack extends Stack { } ``` +# Local Development + +Prerender can be run locally with docker: + +```bash + +docker build lib/prerender --tag prerender:1 +docker run -p 3000:3000 -e TOKEN_SECRET='{"token1": "https://www.emaplesite.com.au"}' -e ENABLE_REDIRECT_CACHE='true' -e ENABLE_PRERENDER_HEADER='true' prerender:1 + + +curl http://localhost:3000/https://www.emaplesite.com.au/home -H 'x-prerender-token: token1' +``` + ## Acknowledgements - [prerender.io](https://prerender.io/) - The Prerender service. From ca292ae50c88744621580bb7a61978aec540b868 Mon Sep 17 00:00:00 2001 From: Jarrod Swift Date: Thu, 13 Jun 2024 15:03:04 +0930 Subject: [PATCH 4/4] Bump minor version --- packages/prerender-fargate/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/prerender-fargate/package.json b/packages/prerender-fargate/package.json index 37ebfe65..4e8b04c1 100644 --- a/packages/prerender-fargate/package.json +++ b/packages/prerender-fargate/package.json @@ -1,6 +1,6 @@ { "name": "@aligent/cdk-prerender-fargate", - "version": "2.4.0", + "version": "2.5.0", "description": "A construct to host Prerender in Fargate", "main": "index.js", "scripts": {