How can I send multiple Set-Cookie headers from API Gateway using a proxied Lambda

后端 未结 5 2039
醉话见心
醉话见心 2021-01-17 09:40

I\'m using API Gateway\'s Proxy integration to call a Lambda. The output format specification is this follow JSON format:

{
  \"statusCode\": httpStatusCode,         


        
5条回答
  •  自闭症患者
    2021-01-17 10:31

    As answered, to date, API Gateway will drop identical keys, only setting one of the cookies.

    However, a workaround exists. You can change the casing of the string 'Set-Cookie' so the keys are not unique. For example, you could use the keys set-cookie, Set-cookie, sEt-cookie, and the headers will be preserved and 3 different cookies would be set.

    Because the RFC standard makes headers case-insensitive this should work with all RFC-compliant clients.

    So, you could rewrite your set-cookie headers, permuting all the possible casings of "Set-Cookie" to get around this.

    This technique (hack) is employed by Zappa, a popular serverless framework written in Python.

提交回复
热议问题