Skip to content

Function

Source: src/AWS/CloudFront/Function.ts

A CloudFront Function for viewer request and response customization.

CloudFront Functions are lightweight JavaScript handlers that run at the edge and can be attached to distribution cache behaviors.

const fn = yield* Function("RouterRequestFunction", {
code: `
async function handler(event) {
event.request.headers["x-forwarded-host"] = {
value: event.request.headers.host.value,
};
return event.request;
}
`,
});