NestJs GraphQL : Unable To set and Get Cookie

NestJs GraphQL : Unable To set and Get Cookie


0

I am working on nestJS Graphql Project , and the problem is that when i send the cookie it is not setting on client and if i manually put the cookie it cant read also , but the thing that amazing me is when i login on sever by graphql playground it is setting the data and working smoothly and also it is showing that when i check login from client it is logged In

My Codes

main.ts

// setting cookie parser
 app.use(cookieParser());

 // cors origin
 app.enableCors({
  origin:true,
  credentials:true
 })

app.module.ts

 GraphQLModule.forRoot<ApolloDriverConfig>({
    driver: ApolloDriver,
     
     autoSchemaFile: join(process.cwd(), 'src/schema.gql'),
     context: ({ req , res }) => ({ req, res }),
     playground:{
       settings: {
         'request.credentials': 'include',
       },
     },
     cors: {
       credentials: true,
       origin: true
     }
  
   }),```

login.resolver.ts

context.res.cookie('__user', val.token, {
           httpOnly: true,
           maxAge: 1000 * 60 * 60 * 24 * 365,
           sameSite: 'none',
           secure: true,
       });```

checkLogin.service.ts

const cookieValue = context.req.cookies['__user']

Share
Improve this question


Load 4 more related questions


Show fewer related questions

0

Reset to default



Browse other questions tagged

or ask your own question.

Leave a Reply

Your email address will not be published. Required fields are marked *