dougmoscrop / serverless-http

Use your existing middleware framework (e.g. Express, Koa) in AWS Lambda 🎉
Other
1.72k stars 165 forks source link

fix: multi valued set-cookie & other headers #168

Closed SachinShekhar closed 3 years ago

SachinShekhar commented 4 years ago

API Gateway lambda proxy integration has special ways to deal with multi valued header which then gets translated to RFC standard adhering multiple separate headers. With event payload version 1.0, a multiValueHeaders array can be returned. With event payload version 2.0, a cookie array can be returned. This PR makes use of these features to replace existing hacks. A salute for creating set-cookie.json file (I literally laughed after seeing it), unfortunately it doesn't work with at least event payload version 2.0 despite it being in adherence with the standard.

dougmoscrop commented 4 years ago

Thank you! I had just kicked myself for not getting around to this yet! Can you add a couple tests?

SachinShekhar commented 4 years ago

@dougmoscrop Done.

vtrifonov commented 3 years ago

This seems to be a breaking change for payload version 1.0 however. You cannot set more than one cookie there because of this change :(

SachinShekhar commented 3 years ago

@vtrifonov I don't think I touched the behavior of payload version 1.0. Did you test your setup with previous version of this library?

vtrifonov commented 3 years ago

yep, it works with 2.5.0, but doesn't work with 2.6.0. Only one of the cookies is set.

SachinShekhar commented 3 years ago

@vtrifonov I rechecked the code changes. Multiple cookies are being returned via multiValueHeaders which is adherence with documentation.

Please, log the response before returning it in Lambda & paste it here. Also, show me what headers web browser is receiving.