dougmoscrop / serverless-http

Use your existing middleware framework (e.g. Express, Koa) in AWS Lambda 🎉
Other
1.71k stars 164 forks source link

`binary: true` does not work #222

Closed rgalanakis closed 2 years ago

rgalanakis commented 2 years ago

If I use servless(app, {binary: true}) as per the docs, the default sniff function errors:

2021-11-24T08:47:20.786Z    4cb6d5ab-6ce3-4f41-9f7a-b119a747ff71    ERROR   Invoke Error    {"errorType":"TypeError","errorMessage":"candidate.replace is not a function","stack":["TypeError: candidate.replace is not a function","   
 at /var/task/node_modules/serverless-http/lib/provider/aws/is-binary.js:21:30","   
 at Array.map (<anonymous>)","    at isBinaryContent (/var/task/node_modules/serverless-http/lib/provider/aws/is-binary.js:20:5)","    at isBinary (/var/task/node_modules/serverless-http/lib/provider/aws/is-binary.js:37:39)"," 
   at module.exports (/var/task/node_modules/serverless-http/lib/provider/aws/format-response.js:21:27)","  
  at Runtime.handler (/var/task/node_modules/serverless-http/lib/provider/aws/index.js:13:12)"," 
   at processTicksAndRejections (internal/process/task_queues.js:95:5)"]}

I believe this is because this line: https://github.com/dougmoscrop/serverless-http/blob/master/lib/provider/aws/is-binary.js#L17 contentTypes ends up being [true].

lordvee commented 2 years ago

I tried it today and got an error as well

dougmoscrop commented 2 years ago

Should be fixed now https://github.com/dougmoscrop/serverless-http/blob/master/lib/provider/aws/is-binary.js#L34