AWS Lambda
The Lambda adapter accepts API Gateway HTTP API payload v2.0, API Gateway REST API payload v1.0, and Lambda Function URLs without configuration. It handles base64 bodies, v2 cookies, v1 multiValueHeaders, and forwards method, path, query, and headers into a standard Request.
- triggerHTTP API v2 · REST v1 · Function URLLambda event payload
- adaptertoLambdaHandler(app)decodes base64, cookies, multiValueHeaders
- coreapp.fetch(Request)routing · hooks · handler
- triggerLambda resultor streamed via toLambdaStreamHandler
When to choose Lambda
- You already run on AWS and want IAM-integrated invocation.
- You want per-request billing without managing a server.
- You need long timeouts (up to 15 minutes) or larger memory than edge functions allow.
Install
The adapter ships with @daloyjs/core. For deployment, use AWS SAM, CDK, the Serverless Framework, or any IaC of your choice.
Function URL or API Gateway HTTP API
Streaming responses
Lambda supports response streaming via awslambda.streamifyResponse. Use the streaming variant of the adapter when you need to flush headers and bytes incrementally (Server-Sent Events, large downloads).
SAM template
DaloyJS requires Node 24 LTS or Node 26+ (engines.node: "^24.0.0 || >=26.0.0"). Use the nodejs24.x managed runtime where available, or ship a container image (see Lambda Web Adapter below) if your region's runtime catalog is older.
Lambda Web Adapter (container deployments)
If you prefer to ship a container image and keep the Node adapter, the AWS Lambda Web Adapter translates Lambda invocations to plain HTTP. Useful when you want one image for both ECS and Lambda.
CloudFront and Lambda@Edge
To serve the API from CloudFront's edge (custom domain, WAF, caching), put CloudFront in front of a Function URL and keep the regular toLambdaHandler(app) entry. Lock the Function URL to CloudFront with origin access control (AuthType: AWS_IAM plus an OAC on the distribution) so nobody can bypass the CDN and its WAF.
CloudFront adds one proxy hop. Declare it so rateLimit() keys on the real client:
Lambda@Edge is not a supported target. It uses a different event shape (Records[0].cf.request), caps request and response bodies far below a normal API, and has no response streaming. Keep edge functions for small header and redirect tweaks, and let the Function URL serve the API.
Gotchas
- Callback-style handlers (
(event, context, callback) => ...) are not supported on supported Node versions. Always useasynchandlers. The DaloyJS adapter does. - For Function URLs with streaming, set
InvokeMode: RESPONSE_STREAMand usetoLambdaStreamHandler. - Cold starts: prefer the Node adapter on provisioned concurrency or use a container with the Web Adapter for warmer reuse.
- Since 1.3.7 the adapter answers
400when the event'sHostheader is not a plainhost[:port]or bracketed IPv6 literal (for example one containing\ / ? # @ %or whitespace). The host is spliced into the request URL, so such a value could otherwise move bytes into the path thatexcept()and other middleware match on. - Since 1.20.0 the adapter also answers
400when the event path contains a.or..segment (in any spelling, including%2e%2e), a backslash,?, or#. API Gateway has already matched a route, and possibly run a route-level authorizer, on that exact path. Turning it into a URL would resolve those segments and could land the request on a different app route than the one the gateway authorized. Encoded slashes (%2F) stay opaque and are not refused. ArequestContextsourceIpthat is not a valid IP address is no longer attached as the peer. X-Forwarded-Protois honoured only when the App declares a proxy (behindProxyset and not"none"), and then only ashttporhttps, read from the last comma-separated entry (the one the nearest proxy appended). Otherwise the scheme ishttps, so a client-sent header can't downgrade the URL your app sees (since 1.5.4; before that, the first entry was honoured without a declared proxy).
See also
- Adapters overview
- Netlify Functions: v1 still uses the same Lambda event shape if you need it.
- Streaming (SSE & NDJSON)