Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/prerender behaviour #1368

Merged
merged 4 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading