Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not setting multiple headers #13

Open
MattyBalaam opened this issue Apr 10, 2024 · 1 comment · May be fixed by #15
Open

Not setting multiple headers #13

MattyBalaam opened this issue Apr 10, 2024 · 1 comment · May be fixed by #15

Comments

@MattyBalaam
Copy link

MattyBalaam commented Apr 10, 2024

Following the pattern outlined here of setting multiple headers works in local node environment: remix-run/remix#231

   return json(
            { success: true },
            {
                headers: [
                    ["Set-Cookie", await commiSession1()],
                    ["Set-Cookie", await commiSession2()]

                ]
            }
        )

However, when running using the createRequestHandler from this package (only tried using AWSProxy.APIGatewayV1) only the last cookie is set.

Looking at the code it may be because you are not returning multiValueHeaders, just headers

https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html

@MattyBalaam MattyBalaam changed the title Not setting multiple headers. Not setting multiple headers Apr 10, 2024
@wingleung
Copy link
Owner

@MattyBalaam hmm I would expect remix to return a valid Headers object, which would mean it should return the following

HeadersList {
  cookies: [ 'cookie1=value1', 'cookie2=value2' ],
  [Symbol(headers map)]: Map(1) {
    'set-cookie' => { name: 'Set-Cookie', value: 'cookie1=value1, cookie2=value2' }
  },
  [Symbol(headers map sorted)]: null
}

👉 https://replit.com/@wingleung1/UnripeSunnyProgrammers

But what I receive from remix is an object containing an array value in headers, which is not compliant with the apigwV1 model

headers: {
  'content-type': 'text/html',
  'set-cookie': [ 'cookie1=chocolate-chip', 'cookie2=oatmeal' ]
}

Created a PR with a workaround 👉 #15

meantime, could you try using comma delimiters?

   const session1 = await commiSession1()
   const session2 = await commiSession2()
 
   return json(
            { success: true },
            {
                headers: {
                    "Set-Cookie": `${session1}, ${session2}`
                }
            }
        )

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

Successfully merging a pull request may close this issue.

2 participants