Reputation: 6977
My Lambda function returns {data: {...}}
body to API Gateway but it can also return {data: {...}, cookie: ...}
if user is logging in.
I added Header Mapping to API Gateway that adds that cookie value to header:
Set-Cookie: integration.response.body.cookie
Now I end up with empty set-cookie
headers if response body has no cookie
. This point also applies to every other header added via Header Mapping.
Is there a way to set header only when value in response body is present?
Upvotes: 0
Views: 568
Reputation: 876
Lambda Proxy Integrations will afford you the dynamic control of response headers you require.
Your Lambda function will need to return the entire HTTP response, including status code, body and headers.
Currently there is no way to dynamically map headers other than to use Proxy Integrations.
Upvotes: 1