`.guard` doesn't guard anymore with `cookie` (both `aot: true & false`)
bogeychan opened this issue · comments
Bogeychan commented
What version of Elysia.JS is running?
1.1.4
What platform is your computer?
WSL Ubuntu
What steps can reproduce the bug?
// index.ts
import { Elysia, t } from "elysia";
const app = new Elysia()
.guard({
cookie: t.Cookie({ session: t.String() }),
})
.get("/", ({ cookie: { session } }) =>
session.value ? session.value : "Empty"
)
.listen(5000);
let response = await app.handle(new Request(`${app.server!.url}`));
console.log(await response.text());
response = await app.handle(
new Request(`${app.server!.url}`, { headers: { Cookie: "session=value" } })
);
console.log(await response.text());
app.stop();
bun run index.ts
What is the expected behavior?
Console output:
{
"type": "validation",
"on": "cookie",
"property": "/session",
"message": "Expected required property",
"expected": {
"session": ""
},
"found": {},
"errors": [
{
"type": 45,
"schema": {
"type": "string"
},
"path": "/session",
"message": "Expected required property"
},
{
"type": 54,
"schema": {
"type": "string"
},
"path": "/session",
"message": "Expected string"
}
]
}
value
What do you see instead?
Console output:
Empty
value
Additional information
This used to work back in version 1.0.27
reported on discord
SaltyAom commented
Bogeychan commented
Closing this as it is working again in the latest version