I’m having an issue with AWS API gateway + Lambda binary responses. I have setup my configuration through serverless. I’m pretty sure I’ve tried everything I could and skimmed most of the documentation of AWS and serverless but I can’t seem to figure it out. Some help would be appreciated.
When calling the associated gateway url I see all actions performed properly up until the response callback. When arriving at the callback the lambda times out and I get a 500 response from the API Gateway with the following content: “message”: “Internal server error” . As seen in the serverless.yml config I’ve upped the timeout to make sure it isn’t a timing issue. The base64 string is never larger than 100kb
Node callback code
callback(null, {
statusCode: 200,
headers: {
"Content-Type": "image/png"
},
body: buffer.toString('base64'),
isBase64Encoded: true
})
Serverless config
provider:
name: aws
runtime: nodejs12.x
region: eu-central-1
lambdaHashingVersion: 20201221
logs:
restApi: true
timeout: 20
apiGateway:
binaryMediaTypes:
- 'image/png'
functions:
lazy:
handler: handler.lazy
vpc:
securityGroupIds:
- xxx
subnetIds:
- xxx
events:
- http:
method: get
path: xxx
response:
contentHandling: CONVERT_TO_BINARY