I have a python lambda function and an API Gateway Lambda Proxy integration.
The python code returns:
{
"statusCode": str(code),
"body": error if error else result.format(**event),
"headers": {
"Content-Type": "application/json",
**kwargs,
}
}
The response in the API Gateway looks like:
Endpoint response body before transformations:
{
"statusCode": "200",
"body": "Some text.",
"headers": {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true,
"kwarg": "foo"
}
}
Mon May 25 20:18:44 UTC 2020 : Method response headers: {Content-Type=application/json, Access-Control-Allow-Origin=*, Access-Control-Allow-Credentials=true, password=1, X-Amzn-Trace-Id=Root=1-5ecc2824-c55ec6e1dc79ba1417361345;Sampled=0}
However, the response to the application loses all of the headers when it reaches the client. The client instead receives:
{
"data":"Some text.",
"status":200,
"statusText":"",
"headers":{
"content-length":"10",
"content-type":"application/json"
},
"config":{
"method":"GET",
"headers":{
"Content-Type":"application/json",
"Accept":"application/json"
},
"timeout":0,
"transformRequest":[
null
],
"transformResponse":[
null
],
"url":"https://something.execute-api.region.amazonaws.com/test/page?foo=bar",
"data":""
}
}
What do I need to change?
Thanks in advance for your help.
kwargsand verify it in CloudWatch?