Skip to content

Commit

Permalink
Merge pull request #1368 from aligent/fix/prerender_behaviour
Browse files Browse the repository at this point in the history
Fix/prerender behaviour
  • Loading branch information
crispy101 authored May 14, 2024
2 parents 1dbe700 + 5fcf558 commit 87dc02a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
3 changes: 1 addition & 2 deletions packages/prerender-proxy/lib/handlers/cache-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ export const handler = async (
const cacheKey = process.env.PRERENDER_CACHE_KEY || "x-prerender-requestid";
const cacheMaxAge = process.env.PRERENDER_CACHE_MAX_AGE || "0";
const response = event.Records[0].cf.response;

if (response.headers[`${cacheKey}`]) {
response.headers["Cache-Control"] = [
response.headers["cache-control"] = [
{
key: "Cache-Control",
value: `max-age=${cacheMaxAge}`,
Expand Down
2 changes: 1 addition & 1 deletion packages/prerender-proxy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aligent/cdk-prerender-proxy",
"version": "2.0.0",
"version": "2.1.4",
"description": "Cloudfront Lambda@Edge constructs for integrating with prerender.io",
"main": "index.js",
"scripts": {
Expand Down
17 changes: 12 additions & 5 deletions packages/static-hosting/lib/static-hosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ export class StaticHosting extends Construct {
const siteNameArray: Array<string> = [siteName];
const enforceSSL = props.enforceSSL !== false;
const enableStaticFileRemap = props.enableStaticFileRemap !== false;
const defaultRootObject = props.defaultRootObject ?? "/index.html";
const errorResponsePagePath = props.errorResponsePagePath ?? "/index.html";
const defaultRootObject = props.defaultRootObject ?? "index.html";
const errorResponsePagePath = props.errorResponsePagePath ?? "index.html";
const defaultBehaviorEdgeLambdas = props.defaultBehaviorEdgeLambdas ?? [];
const disableCSP = props.disableCSP === true;

Expand Down Expand Up @@ -427,14 +427,21 @@ export class StaticHosting extends Construct {
const originRequestPolicy =
props.defaultBehaviorRequestPolicy ||
new OriginRequestPolicy(this, "S3OriginRequestPolicy", {
headerBehavior:
OriginRequestHeaderBehavior.allowList("x-forwarded-host"),
headerBehavior: OriginRequestHeaderBehavior.allowList(
"x-forwarded-host",
"x-request-prerender",
"x-prerender"
),
});

const originCachePolicy =
props.defaultBehaviorCachePolicy ||
new CachePolicy(this, "S3OriginCachePolicy", {
headerBehavior: CacheHeaderBehavior.allowList("x-forwarded-host"),
headerBehavior: CacheHeaderBehavior.allowList(
"x-forwarded-host",
"x-request-prerender",
"x-prerender"
),
enableAcceptEncodingBrotli: true,
enableAcceptEncodingGzip: true,
});
Expand Down

0 comments on commit 87dc02a

Please sign in to comment.