Skip to content

Commit

Permalink
Merge pull request #1386 from aligent/feature/prerender-redirect-resp…
Browse files Browse the repository at this point in the history
…onse

Feature/prerender redirect response
  • Loading branch information
jswift authored Jun 13, 2024
2 parents bd72b65 + ca292ae commit 12bbef3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
13 changes: 13 additions & 0 deletions packages/prerender-fargate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions packages/prerender-fargate/lib/prerender/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion packages/prerender-fargate/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 12bbef3

Please sign in to comment.