dougmoscrop / serverless-http

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

Elastic Load Balancer reverses order of `multiValueHeaders` #244

Open laverdet opened 1 year ago

laverdet commented 1 year ago

I noticed this issue and I'm not sure how long it's been around. I opened a similar issue at vendia/serverless-express#554 since we use both of these packages. AWS Elastic Load Balancer is reversing the order of header values specified in multiValueHeaders. Is this something that you've seen before?

exports.handler = async (event) => ({
  statusCode: 200,
  body: JSON.stringify(event),
  isBase64Encoded: false,
  cookies: [
    'a=1',
    'a=2',
  ],
  multiValueHeaders: {
    'x-set-cookie': [
      'a=1',
      'a=2'
    ],
  },
  'content-type': [ 'text/plain' ],
});
-> % curl -vv http://lambd-LoadB-1DYPW4EWVLYCT-1230052677.us-east-1.elb.amazonaws.com 2>&1 | grep -i set-cookie
< x-set-cookie: a=2
< x-set-cookie: a=1

We can workaround it obviously but I'm wondering if this is a new issue or if ELB has always been broken, or if it's only broken in certain circumstances.