Binary and CORS support does not work togather
See original GitHub issueBug Report
Description
- 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.
- 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
- What should’ve happened? A 200 response should have been returned as with binary support disabled.
- 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'
- 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:
- Created 4 years ago
- Comments:10 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
Thanks @prasanthsd for that report. We’re definitely open for PR that brings that into the framework