Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

serverless-binary-cors

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-binary-cors

A Serverless framework plugin to enable proper cors when APIGateway has binary media types configured

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1.7K
increased by26.69%
Maintainers
1
Weekly downloads
 
Created
Source

serverless-binary-cors

A Serverless framework plugin to enable proper CORS when APIGateway has binary media types configured

Install

npm install serverless-binary-cors
or
yarn add serverless-binary-cors

Note

This is an early implementation of this plugin. So far it's working for all my use cases, but has not been tested in many other configurations. It could need additional work to handle all possible setups. Your contributions are appreciated.

The Problem

When enabling Binary Media Types in API Gateway, the most flexible setting is to use */* as it does not require a client to send an Accept: header. However, this then starts causing OPTIONS methods to begin failing with 500 errors due API Gateway not knowing how to encode the response.

The Solution

After multiple calls with AWS Support (as this is totally undocumented), we landed on a solution which is to modify the Integration Response of the MOCK integration that is used to handle these OPTIONS methods. The trick is to use an actual binary Content-Type in the Mapping Templates.

Mapping Template

Getting this to configure with Serverless requires modifying the underlying CloudFormation templates.

This plugin makes those nessisary modification.

FAQs

Package last updated on 20 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc