Skip to content

CloudFrontResponse

reference
1 min readUpdated

Kind: Interface

Source: src/adapter/lambda-edge/handler.ts

Part of: Adapter

CloudFrontResponse represents the response object returned by a Lambda@Edge handler. It carries CloudFront-formatted headers and string status details that CloudFront reads when sending a response.

Properties

PropertyType
headersCloudFrontHeaders
statusstring
statusDescriptionstring

Diagram

mermaid
graph LR
  Handler[Lambda Edge Handler] --> Response[CloudFrontResponse]
  Response --> Headers[CloudFrontHeaders]
  Response --> Status[status]
  Response --> Description[statusDescription]
  Response --> CloudFront[CloudFront]

Usage

ts
import type { CloudFrontHeaders, CloudFrontResponse } from './handler';

function createResponse(
  headers: CloudFrontHeaders,
  status: string,
  statusDescription: string,
): CloudFrontResponse {
  return {
    headers,
    status,
    statusDescription,
  };
}

const response = createResponse(
  requestHeaders,
  responseStatus,
  responseDescription,
);

AI Coding Instructions

  • Return CloudFrontResponse from Lambda@Edge handlers when constructing a CloudFront response.
  • Keep headers in the CloudFrontHeaders format expected by CloudFront.
  • Set both status and statusDescription as strings.
  • Preserve header names and values required by the response path.

How it works

CloudFrontResponse is an exported TypeScript interface for the optional response member of a CloudFront event record’s cf object. src/adapter/lambda-edge/handler.ts:56-60 src/adapter/lambda-edge/handler.ts:69-75

When handle() invokes the Hono application, it places the incoming event’s optional cf.response value in the fetch context as response. src/adapter/lambda-edge/handler.ts:128-141 The adapter does not otherwise read, validate, transform, or return that value in this file; response conversion instead operates on the Response returned by the application and creates a separate internal CloudFrontResult shape. src/adapter/lambda-edge/handler.ts:149-162

Was this page helpful?

Download as PDF
CloudFrontResponse — Hono (narrator proof)