• Pricing
© 2026 Serverless, Inc. All rights reserved.

Framework

  • Overview
  • Documentation
  • Plugins360
  • Pricing

Learn

  • Blog
  • GuidesUpdated
  • Examples240
  • Courses

Resources

  • Support
  • Security
  • Trust Center
  • Status

Community

  • Slack
  • GitHub47k
  • Forum
  • Meetups

Company

  • About
  • Careers
  • Contact
  • Partners

Legal

  • Terms of Service
  • Privacy Policy
  • Trademark
  • DMCA
GFG

Serverless Apigateway Plugin

by

Configure the AWS api gateway: Binary support, Headers and Body template mappings

0
10
  1. Serverless Apigateway Plugin

serverless-APIGateway-plugin

Serverless framework plugin to configure the AWS api gateway

  • Binary support
  • Headers
  • Body template mappings

Currently it is used in GFG(Global Fashion Group) internal projects.

Installation

Install the plugin from npm

$ npm install --save serverless-apigateway-plugin

Usage

Add the plugin to your serverless.yml

# serverless.yml

plugins:
  - serverless-apigateway-plugin

Add the config to your custom tag of serverless.yml,

For headers: pls follow the spec at AWS JS SDK putGatewayResponse For body mapping templates: pls follow the spec at AWS JS SDK updateGatewayResponse

# serverless.yml

custom:
  apigateway:
    responses:
    -  response:
         type: ACCESS_DENIED
         headers: {"gatewayresponse.header.Access-Control-Allow-Origin":"'*'"}
         bodyMappingTemplate: { "contentType": "application/json" , "content": '{"status": 403,"code": "INVALID_TOKEN","detail":$context.error.messageString}'}
         statusCode: 403
    binaryTypes:
      - 'image/jpg'
      - 'text/html'

Contributing

We welcome pull requests! Please fork the repo and submit your PR.

Contents

  • serverless-APIGateway-plugin
  • Installation
  • Usage
  • Contributing

Related

GuidesPluginsExamplesSlack CommunitySupport