Hello guys, i got a problem with the .verify method of the @elysia/jwt package.
I'm trying to verify a my jwt token but it doesn't work and return false.
jwt.io tell me there is nothing wrong with my token
here is my code:
const jwt = await jwtAccess.verify(cookie!.access_token);
console.log("Test verify JWT", jwt, cookie!.access_token);
if (!jwt) {
set.status = 401;
return {
success: false,
message: "Unauthorized",
errors: "Invalid access token",
};
}
this code is in a middleware, and the cookie is set in the request.
the code of the jwtAccess.verify method is:
export const jwtAccessSetup = new Elysia({
name: "jwtAccess",
}).use(
jwt({
name: "jwtAccess",
schema: t.Object({
userId: t.String(),
}),
secret: process.env.JWT_ACCESS_SECRET || "DO NOT USE THIS SECRET KEY",
exp: 30 * 24 * 60 * 60,
})
);
every time i want to check the jwt, it returns me false but when i check it with the jwt.io debugger, it works.
Even this, return false 💀
const test = await jwtAccess.sign({ userId: "652e83d3b47c67a8d823daa6" });
console.log("@Cookie verify", await jwtAccess.verify(test));```
is there a problem with the verify method or am i doing something wrong?
full repo: <https://github.com/ImJustLucas/bun-elysia-boilerplate/tree/master>