elysia
elysia copied to clipboard
Reading a cookie value results in the cookie beeing set again
What version of Elysia is running?
1.1.17
What platform is your computer?
Linux 5.15.153.1-microsoft-standard-WSL2 x86_64 unknown
What steps can reproduce the bug?
When reading a cookie that is present a set-cookie header is added to the response, even when no new cookie value is set.
To reproduce just create a new Elysia project (bun create elysie) and copy the following code into src/index.ts
import { Elysia } from 'elysia';
new Elysia()
.get('/', () => 'Hello Elysia')
.get('/set', ({ cookie: { test } }) => {
test.value = Math.random().toString();
return {
value: test.value,
};
})
.get('/get', ({ cookie: { test } }) => {
return {
value: test.value,
};
})
.listen(3000, (server) => {
console.log(`🦊 Elysia is running at ${server.url}`);
});
Steps to reproduce:
- visit
http://localhost:3000/get->set-cookieheader is not present - visit
http://localhost:3000/set->set-cookieheader is present - visit
http://localhost:3000/get->set-cookieheader is present
What is the expected behavior?
The cookie is not set again
What do you see instead?
The cookie is set again.
Additional information
The session cookie i use in my session service gets set over and over. That itself is not that big of a deal in terms of functionality, but due to missing informations about the cookie lifetime for example the cookie is always set using the default options (no path, no domain, no secure, no httpOnly, ...).
Have you try removing the node_modules and bun.lockb and try again yet?
yes