question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Binary and CORS support does not work togather

See original GitHub issue

Bug Report

Description

  1. What did you do? Enabled binary media support and enabled cors support for each of the methods in serverless.yml. Setting cors true for the method creates OPTIONS request for the API GW endpoint and a MOCK end point is associated with the request. All of the stuff are created by the serverless framework deploy command without any manual configurations.
  2. What happened? API GW returns a 500 response with message “Internal server error” for OPTIONS requests when binary support is enabled and returns a proper 200 response otherwise when I remove “binaryMediaTypes” from serverless.yml and redeploy. When it returns a 500 response the below log entries can be seen for the API GW:
18:18:11 Method request body before transformations: [Binary Data]
18:18:11 Execution failed due to configuration error: Unable to transform response
  1. What should’ve happened? A 200 response should have been returned as with binary support disabled.
  2. What’s the content of your serverless.yml file?
provider:
  apiGateway:
    binaryMediaTypes:
      - '*/*'

functions:
  someRandomFunction:
    handler: src/handlers/someHandler.getSomeData
    events:
      - http:
          path: getdata
          method: get
          cors: true

resources:
 Resources:
    GatewayResponseDefault4XX:
      Type: 'AWS::ApiGateway::GatewayResponse'
      Properties:
        ResponseParameters:
          gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
          gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
        ResponseType: DEFAULT_4XX
        RestApiId:
          Ref: 'ApiGatewayRestApi'
  1. What’s the output you get when you use the SLS_DEBUG=* environment variable (e.g. SLS_DEBUG=* serverless deploy) Deployment is a success and no errors are reported.

Similar or dependent issues: Similar discussions that I have found are linked below https://forums.aws.amazon.com/thread.jspa?threadID=256140

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
prasanthsdcommented, Jan 22, 2020

Finally found this after lots of searching around.

https://github.com/duro/serverless-binary-cors

This is not a serverless framework bug but rather a AWS thing which is not documented by them. But would be great to incorporate what this plugin does to the serverless framework itself if binary and cors is enabled at the same time in serverless.yml

1reaction
medikoocommented, Jan 23, 2020

Thanks @prasanthsd for that report. We’re definitely open for PR that brings that into the framework

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enabling binary media types breaks Option POST call (CORS ...
Basically, this bug report says the problem is having CORS enabled while also using the generic Binary Media Type "*/*" .
Read more >
Working with binary media types for REST APIs
Set up content encoding conversion in API Gateway to support binary media types. ... If this property and the contentHandling property are not...
Read more >
Cross-Browser support with Cross-Origin isolation
Adding cross-browser support for WebContainers is not as easy as you might think. Let's explore the journey of cross-origin isolation together.
Read more >
Configure cross-origin resource sharing (CORS) | Cloud Storage
Check that you are not making a request to the storage.cloud.google.com endpoint, which doesn't allow CORS requests. For more information about supported ......
Read more >
We Still Don't Have Secure Cross-Domain Requests - USENIX
of CORS are subject to a number of new security issues: 1) CORS relaxes the ... ploiting victim's internal binary-protocol services,.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found