javascript - Where should i store my JSON Web Token for a 'non-singlepage' frontend application -


i've built simple rest api hapijs using jwt auth method. want build pure es6 frontend, not have spa (there more 1 .html file).

my question: best way store jwt after login. local storage, cookie ?

if store in cookie, you'll vulnerable csrf attack, because browser automatically send token each request. see more information on these type of attacks:

https://en.wikipedia.org/wiki/cross-site_request_forgery

i recommend storing in localstorage , sending token via head of requests. note: browser doesn't automatically you!

example:

x-access-token: bearer -jwt goes here- 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -