Should JWT be stored in localStorage or cookie?
问题 For the purpose of securing REST API using JWT, according to some materials (like this guide and this question), the JWT can be stored in either localStorage or Cookies . Based on my understanding: localStorage is subjected to XSS and generally it's not recommended to store any sensitive information in it. With Cookies we can apply the flag "httpOnly" which mitigates the risk of XSS. However if we are to read the JWT from Cookies on backend, we then are subjected to CSRF. So based on the