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

Setting multiple cookie in same request not working #604

Closed
anilmagzter opened this issue Apr 17, 2024 · 5 comments
Closed

Setting multiple cookie in same request not working #604

anilmagzter opened this issue Apr 17, 2024 · 5 comments
Labels
p1-important Unpleasant bugs, Blocking an upgrade

Comments

@anilmagzter
Copy link

If we set more than one cookie in the same request, only the last one is used.

For example
cookies.set('first', 'true', { path: '/' });
cookies.set('second', 'selected', { path: '/' });

Only the 'second' cookie is in the response and 'first' is ignored. Is it related to sveltejs/kit#3460 (comment)

@jill64
Copy link
Owner

jill64 commented Apr 19, 2024

Thank you for opening this issue!

I have confirmed that the problem occurs.
Note the location of the obstruction for your records.

1. Buffered Response

It appears that the Set-Cookie header needs to be set using the cookie field.

return {
statusCode: response.status,
headers: Object.fromEntries(response.headers),
body: await response.text()
} satisfies LambdaResponsePayload

It is planned to be implemented in v1.6.0.

2. Streaming Response

I did some research, but couldn't find a workaround.

https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/

It seems like there needs to be a way to set cookies other than using standard headers.

export const qualified = (
responseStream: ResponseStream,
{
awslambda,
statusCode,
headers
}: {
statusCode: number
headers: Record<string, string>
awslambda: typeof AwsLambda
}
) =>
awslambda.HttpResponseStream.from(responseStream, {
statusCode,
headers
})

Does anyone know a solution regarding this?

@jill64 jill64 added p1-important Unpleasant bugs, Blocking an upgrade need-opinion We need ideas from community labels Apr 19, 2024
@jill64
Copy link
Owner

jill64 commented Apr 28, 2024

edge-bundled is not working as well

@jill64 jill64 added the upstream Blocked by upstream issues label Apr 28, 2024
@jill64
Copy link
Owner

jill64 commented Apr 28, 2024

After researching, it seems that with Lambda@edge and streaming responses, only a single key can be specified in HTTP headers, and multiple cookies cannot be returned.

This is an issue with the AWS Lambda platform and seems difficult to work around.

@jill64
Copy link
Owner

jill64 commented Apr 29, 2024

It was possible to return multiple headers with Lambda@Edge.
Available in v1.7.2.
I will continue to investigate the use of streaming responses.

@jill64 jill64 removed upstream Blocked by upstream issues need-opinion We need ideas from community labels Apr 29, 2024
@jill64
Copy link
Owner

jill64 commented Apr 29, 2024

It was possible to return multiple cookies with streaming response.
Available in v1.8.0

@jill64 jill64 closed this as completed Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p1-important Unpleasant bugs, Blocking an upgrade
Projects
None yet
Development

No branches or pull requests

2 participants