I have Next.js project where I use next-auth and I use node.js for the server. when user log in system, their session should pass to nodejs like this:
this code is part of […nextAuth].ts
events: {
async signIn({ user }: any) {
const { PASS_SESSION_SERVER } = Operation.Mutations;
const { data } = await ApolloClient.mutate({
mutation: PASS_SESSION_SERVER,
variables: {
sessionUser: {
id: user.id,
email: user.email,
name: user.name,
},
},
});
},
},
after I receive the session I store on the Redis successfully like that:
consider that this function is the mutation
getSession: async (_: any, args: any, { prisma, req }: GraphqlContext) => {
const { sessionUser } = args;
try {
const user = req.session.user;
if (!sessionUser || user) return false;
req.session.user = sessionUser;
console.log("[getSession Mutation] ============================= ");
console.log(req.session);
return true;
} catch (error) {
throw error;
}
},
and when I try to access session to get user data I receive only cookie options:
Session {
cookie: {
path: '/',
_expires: 2023-12-10T03:58:52.157Z,
originalMaxAge: 604800000,
httpOnly: false,
secure: false
}
}
but the interesting fact is that when I do everything from the "Apollo server tool", everything works fine and I get the session without any extra problems.
I think the problem is that when I pass a session from client-side to server-side.
so I need your help