yarbsemaj / sveltekit-adapter-lambda

An adapter to build a SvelteKit app into a lambda ready for deployment with lambda proxy via the Serverless Framework or CDK.
https://www.npmjs.com/package/@yarbsemaj/adapter-lambda
MIT License
77 stars 16 forks source link

Multiple `set-cookie` headers from endpoints returned as single value #15

Closed coderpradp closed 2 years ago

coderpradp commented 2 years ago

Currently set-cookie header with multiple value (array) is being returned as comma separated single value. Browsers can't interpret it correctly and only sets first value before comma in browser cookie.

adapter-netlify (code) seems to solve this by returning multivalued set-cookie header without joining it into single value.

Will it be possible for this adapter to support this in similar way?

Edit: Added Reproduction This endpoint:

export function get() {
  return {
    headers: {
      'set-cookie': [
        'accesstoken=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly;',
        'refreshtoken=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly;'
      ]
    }
  }
}

produces the following headers:

set-cookie: accesstoken=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly, refreshtoken=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly

but it should produce:

set-cookie: accesstoken=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly
set-cookie: refreshtoken=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly
yarbsemaj commented 2 years ago

Hi @coderpradp Thank You for your interest in my project! I have just published a new version of the adapter 0.9.4 that I believe fixes this issue, please let me know if not 😄

coderpradp commented 2 years ago

@yarbsemaj Thank you. It is working perfectly now.