Skip to content

Support API Gateway Response Streaming #287

Closed

Description

@filipe-cantarelli

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

Introduce a new disableBase64Encoding option that disables Base64 encoding and ensures the isBase64Encoded property is not included in the response.

I implemented this in my fork here:
https://github.com/filipe-cantarelli/aws-lambda-fastify

Since this adds a new option, I wanted to check with the community first and get some feedback before opening a pull request.

Motivation

API Gateway response streaming does not support the isBase64Encoded property (see: https://aws.amazon.com/blogs/compute/building-responsive-apis-with-amazon-api-gateway-response-streaming/
).

A practical workaround is to introduce a disableBase64Encoding option, which disables Base64 encoding and prevents the isBase64Encoded property from being included in the response.

Example

import { pipeline } from 'node:stream/promises';
import awsLambdaFastify from '@fastify/aws-lambda';
import { app } from './app.js';


const proxy = awsLambdaFastify(app, { payloadAsStream: true, disableBase64Encoding: true })
export const handler = awslambda.streamifyResponse(async (event, responseStream, context) => {
    const { meta, stream } = await proxy(event, context)
    responseStream = awslambda.HttpResponseStream.from(responseStream, meta)
    console.error(meta);
    await pipeline(stream, responseStream)
})
await app.ready() // https://github.com/fastify/aws-lambda-fastify/issues/89

Activity

  1. adrai commented on Dec 17, 2025

    @adrai
    Member

    Did not had time to test the new streaming capabilities... but sounds good.
    Please feel free to open a PR.
    Please add some dedicated tests.

  2. adrai commented on Dec 17, 2025

    @adrai
    Member

    btw. maybe we could set disableBase64Encoding to true by default if payloadAsStream = true and the using api-gateway (not alb)...?

    we could check for requestContext?.alb: https://docs.aws.amazon.com/lambda/latest/dg/services-alb.html

    What do you think?

  3. filipe-cantarelli commented on Dec 17, 2025

    @filipe-cantarelli
    ContributorAuthor

    btw. maybe we could set disableBase64Encoding to true by default if payloadAsStream = true and the using api-gateway (not alb)...?

    we could check for requestContext?.alb: https://docs.aws.amazon.com/lambda/latest/dg/services-alb.html

    What do you think?

    I think that works, as people would often forget to add this. But we still want to have the option to override it, right?

  4. adrai commented on Dec 17, 2025

    @adrai
    Member

    I think that works, as people would often forget to add this. But we still want to have the option to override it, right?

    yes

  5. filipe-cantarelli commented on Dec 17, 2025

    @filipe-cantarelli
    ContributorAuthor
  6. github-actions commented on Sep 1, 2026

    @github-actions
    Contributor

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  7. locked as resolved and limited conversation to collaborators on Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions