hiteshchoudhary / chai-backend

A video series on chai aur code youtube channel
5.06k stars 760 forks source link

cookie not set #40

Open kunalrisaanva opened 9 months ago

kunalrisaanva commented 9 months ago

.cookie("accessToken", accesToken, options) .cookie("refreshToken", refreshToken, options)

In cookie options secure:true not working what should i do

TechWhiz03 commented 9 months ago

not working in what sense? is the cookie not sent by the server or you are unable to see it in postman

if you are not able to see it in postman:

kunalrisaanva commented 9 months ago

not working in what sense? is the cookie not sent by the server or you are unable to see it in postman

if you are not able to see it in postman:

  • check the cookies either in header section or
  • click on cookie text below send button

In options when i did cookie secure option true it will not set and when i did this secure option commented cookie are set and seeing in postman. So the problem is in options httpOnly working secure true not working

TechWhiz03 commented 9 months ago

Sometimes, servers might set cookies with specific attributes (like HttpOnly or Secure) that prevent them from being accessed by client-side JavaScript. These cookies won't be visible in the "Cookies" section of Postman.

So try accessing cookies either in header or below the send button in postman, without commenting secure options

kunalrisaanva commented 9 months ago

Sometimes, servers might set cookies with specific attributes (like HttpOnly or Secure) that prevent them from being accessed by client-side JavaScript. These cookies won't be visible in the "Cookies" section of Postman.

So try accessing cookies either in header or below the send button in postman, without commenting secure options

if that prevent them from being accessed by client-side JavaScript. then how it accessed by in video. in that video cookies are visible in postman of hitesh sir

Sreejit-Sengupto commented 9 months ago

not working in what sense? is the cookie not sent by the server or you are unable to see it in postman if you are not able to see it in postman:

  • check the cookies either in header section or
  • click on cookie text below send button

In options when i did cookie secure option true it will not set and when i did this secure option commented cookie are set and seeing in postman. So the problem is in options httpOnly working secure true not working

Are you getting 'undefined'? If yes then check if you are awaiting before destructuring the tokens from generateTokensfunction const { accessToken, refershToken } = await generateTokens()

kunalrisaanva commented 9 months ago

not working in what sense? is the cookie not sent by the server or you are unable to see it in postman if you are not able to see it in postman:

  • check the cookies either in header section or
  • click on cookie text below send button

In options when i did cookie secure option true it will not set and when i did this secure option commented cookie are set and seeing in postman. So the problem is in options httpOnly working secure true not working

Are you getting 'undefined'? If yes then check if you are awaiting before destructuring the tokens from generateTokensfunction const { accessToken, refershToken } = await generateTokens()

Tokens are genrated properly. But with secure true option they are not getting in postman so the problem is secure true option not working

Sreejit-Sengupto commented 9 months ago

not working in what sense? is the cookie not sent by the server or you are unable to see it in postman if you are not able to see it in postman:

  • check the cookies either in header section or
  • click on cookie text below send button

In options when i did cookie secure option true it will not set and when i did this secure option commented cookie are set and seeing in postman. So the problem is in options httpOnly working secure true not working

Are you getting 'undefined'? If yes then check if you are awaiting before destructuring the tokens from generateTokensfunction const { accessToken, refershToken } = await generateTokens()

Tokens are genrated properly. But with secure true option they are not getting in postman so the problem is secure true option not working

I didn't encounter that problem 🤔

ganeswar07 commented 9 months ago

Check both tokens before sending response

kunalrisaanva commented 9 months ago

Check both tokens before sending response They are created properly they are received from func

ganeswar07 commented 9 months ago

Share your repo link

kunalrisaanva commented 9 months ago

Share your repo link

Check my profile link will be there

aakash6789 commented 8 months ago

I have solved the issue, please reply if you still need help

SaunakNandi commented 8 months ago

Guys but in thunderClient the cookies are visible and also secure is set to true;

SaunakNandi commented 8 months ago

I have solved the issue, please reply if you still need help

@aakash6789 can you look into the issue 88?

kunalrisaanva commented 8 months ago

I have solved the issue, please reply if you still need help

I figured out secure true options required https protocol not http

aakash6789 commented 8 months ago

I have solved the issue, please reply if you still need help

@aakash6789 can you look into the issue 88?

@SaunakNandi the catch is that accessToken and refreshToken are returned as promises, so to set them first you need to reolve them. Try this if you are unable to solve the issue, you can always check my repo