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
Post a Comment