Session empty on Elysia server but works on Nextjs client

I have a Elysia server running on port 3002 and my Next.js client running on port 3001. When I signup I'm able to hit the server fine and create a session which is saved to a cookie, but whenever I try and make a request to the server the session is null. I have a guard on each route I want to check the session. I included credentials: "include" on my client request as well
export const AuthMacro = new Elysia({ name: "auth" })
.mount("/auth", auth.handler)
.macro({
auth: {
async resolve({ status, request: { headers } }) {
console.log(headers);
const session = await auth.api.getSession({
headers,
});
console.log("server session", session);

if (!session) return status(401);

return {
user: session.user,
session: session.session,
};
},
},
});
export const AuthMacro = new Elysia({ name: "auth" })
.mount("/auth", auth.handler)
.macro({
auth: {
async resolve({ status, request: { headers } }) {
console.log(headers);
const session = await auth.api.getSession({
headers,
});
console.log("server session", session);

if (!session) return status(401);

return {
user: session.user,
session: session.session,
};
},
},
});
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?