Skip to content

Commit

Permalink
enhance code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Park committed Sep 5, 2024
1 parent 7f97cb6 commit cf37d62
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/static-hosting/lib/path-remap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class PathRemapFunction extends Construct {
local: new Esbuild({
entryPoints: [join(__dirname, "handlers/remap.ts")],
define: {
"process.env.REMAP_PATH": '"' + options.path + '"',
"process.env.REMAP_PATH": `"${options.path}"`,
},
}),
},
Expand Down
9 changes: 4 additions & 5 deletions packages/static-hosting/lib/static-hosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,25 +435,24 @@ export class StaticHosting extends Construct {
});
let backendOrigin = undefined;

const additionalDefaultOriginRequestHeaders =
props.additionalDefaultOriginRequestHeaders || [];
const originRequestHeaderBehaviorAllowList = [
"x-forwarded-host", // Consumed by OriginRequest Lambda@Edge for Feature Environment functionality.
"x-request-prerender", // Consumed by OriginRequest Lambda@Edge to determine if this request needs to be send to Prerender service rather than other origins.
"x-prerender-host", // Consumed by OriginRequest Lambda@Edge, only when x-request-prerender header is set. Prerender service will send request to this host.
"x-prerender", // Consumed, if configured, by origin's custom features, such as GeoRedirection, the behave of which should depend on whether the request is from an end user.
"x-prerender-user-agent", // Consumed by Prerender service for logging original user agent rather than CloudFront's
...additionalDefaultOriginRequestHeaders,
];
if (props.additionalDefaultOriginRequestHeaders) {
props.additionalDefaultOriginRequestHeaders.forEach(header => {
originRequestHeaderBehaviorAllowList.push(header);
});
}
const originRequestPolicy =
props.defaultBehaviorRequestPolicy ||
new OriginRequestPolicy(this, "S3OriginRequestPolicy", {
headerBehavior: OriginRequestHeaderBehavior.allowList(
...originRequestHeaderBehaviorAllowList
),
});

const cacheHeaderBehaviorAllowList = [
"x-forwarded-host", // Origin response may vary depending on the domain/path based on Feature Environment
"x-prerender", // Origin response may vary depending on whether the request is from end user or prerender service.
Expand Down

0 comments on commit cf37d62

Please sign in to comment.