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. 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() diff --git a/packages/prerender-fargate/package.json b/packages/prerender-fargate/package.json index 3cb9fcb1..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.3.8", + "version": "2.5.0", "description": "A construct to host Prerender in Fargate", "main": "index.js", "scripts": {