Skip to content

Elysia send set-cookie header for each request #1556

@akim-bow

Description

@akim-bow

What version of Elysia is running?

1.4.16

What platform is your computer?

Darwin 24.6.0 arm64 arm

What environment are you using

bun 1.3.1

Are you using dynamic mode?

no

What steps can reproduce the bug?

new Elysia()
	.guard({
		cookie: t.Cookie({
			value: t.Optional(
				t.Object({
					a: t.String(),
					b: t.String(),
				}),
			),
		}),
	})
	.get("/cookie", ({ cookie: { value } }) => value.value)
	.post("/cookie", ({ cookie: { value } }) => {
		value.value = { a: "1", b: "2" };
	})
	.listen(3001);

Send 2 requests:
POST http://localhost:3001/cookie
then
GET http://localhost:3001/cookie

What is the expected behavior?

I expect to receive set-cookie header in POST response only.

What do you see instead?

Instead, i also receive set-cookie header for GET request. In reality, i was receiving set-cookie header in all other requests.

Additional information

No response

Have you try removing the node_modules and bun.lockb and try again yet?

yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions