0

[enter image description here][1]Im developed web app react frontend and node backend.when user login I try to save cookie in browser .in postman testing cookie show but not save in browser.(I used also jwt authentication)In browser this error show,* Indicate whether a cookie is intended to be set in a cross-site context by specifying its SameSite attribute* .and I update with sameSite none and secure true but still not save cookie in browser.How to slove this

2 Answers2

0

Did you enable the Cors middleware on the server-side? Here's how you can do it How to enable cors nodejs with express?

nicklee
  • 55
  • 1
  • 7
0

If you are hosting your web app on localhost you should set secure:false or else cookies are not going to work. You should set secure:true only when you deploy your web app. The reason is setting this option to true says that the cookies should be send over https (secure) connection but when you are on localhost you are on http (not secure) connection so coookies will not be sent. For more info check a previous question:

Why setting the cookie.secure to True in express session allows session id and data to persist?

PTsag
  • 108
  • 2
  • 9
  • I do but not save cookie below is the error message .It says my accessToken Affected Resolve this issue by updating the attributes of the cookie: Specify SameSite=None and Secure if the cookie is intended to be set in cross-site contexts. Note that only cookies sent over HTTPS may use the Secure attribute. Specify SameSite=Strict or SameSite=Lax if the cookie should not be set by cross-site requests. 1 cookie Name Domain & Path accessToken localhost/ – Tharindu Madhushan Apr 28 '23 at 10:57
  • Please edit your question and copy paste your code and the error. – PTsag Apr 28 '23 at 11:11