i´m using nextjs, graphql and JWT on my app and I can´t find a good logic to send the cookie with the token inside from the server, so I found another logic based on create the cookie on the client when the server send me the token.
Is it insecure? Is a bad practice or there is any difference between creating cookies on the server or on the cliente? I´m using HTTP cookies.
this is my code on the client where I create the cookie:
const handleSubmit = async (e)=>{
e.preventDefault();
createUser({variables: {nombre, apellidos, email, password}}).then(res=>{
console.log(res.data.register)
cookies.set("token", res.data.register,{sameSite:'strict', expires: new Date(new Date().getTime() + 5 * 140000000), httpOnly: true})
})
In res.data.register is the token(JWT) created by server.