Skip to content
This repository has been archived by the owner on Sep 8, 2021. It is now read-only.

Headers not being passed back to ALB #41

Open
shamimmirzai opened this issue Jun 13, 2019 · 1 comment
Open

Headers not being passed back to ALB #41

shamimmirzai opened this issue Jun 13, 2019 · 1 comment

Comments

@shamimmirzai
Copy link

Firstly thanks for this awesome project. I have my lambda functions being called by the ALB and it looks like the headers that I set in my php code are not being sent back in the headers field of the json response back to the ALB. Therefore, I cannot set the content type for my responses so they always end up being octet-stream. This is my very simple php function:

<?php
  header('Content-Type: text/html');
  phpinfo();
?>

and when the response reaches my browser via the ALB, the content type is the default octet-stream. According to the AWS Lambda Functions as Targets the response that bootstrap needs to send back to the ALB must be json like this:

{
    "isBase64Encoded": false,
    "statusCode": 200,
    "statusDescription": "200 OK",
    "headers": {
        "Set-cookie": "cookies",
        "Content-Type": "application/json"
    },
    "body": "Hello from Lambda (optional)"
}

I could be mistaken, but I believe bootstrap is failing to set the headers field in that json response.

Any assistance would be appreciated. Thanks.

@daftspunk
Copy link

To solve this issue, enable Multi value headers in AWS:

  1. Open AWS console
  2. Navigate to EC2 > Load Balancing > Target Groups
  3. Select relevant Target Group
  4. Click Edit under Attributes
  5. Set Multi value headers to Enabled

The proper headers should return now

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants