How to store JWT token properly using Laravel 5.4 and Vue.js 2
I’m writing an API using Laravel 5.4 and connect to it from frontend written in Vue.js 2. After login API gets back a token to me, so how and where should I store the token in a frontend? Now, I’m using localStorage for that but it doesn’t seem to be a right way.
This is how I check for token:
router.beforeEach((to, from, next) => {
if(to.meta.requiresAuth) {
if(store.getters.logged || window.localStorage.getItem('access_token')) {
next();
}
else {
next('/login');
}
}
else {
next();
}
});
from Laravel Questions and Answers https://laravelquestions.com/laravel/how-to-store-jwt-token-properly-using-laravel-5-4-and-vue-js-2/
via Lzo Media
Hi, ExpressTech laravel Development Service provide fluency in delivering simple code for a variety of bundles to help create effective and Secure websites for Various fields of industry and domains. We help businesses to achieve their estimated goals using leading solutions from the Laravel framework.
ReplyDelete