Vue SPA, router guard with redirect after login

While making Let’s Organise SPA(Single page Application) I bumped into the issue of properly checking Auth and redirecting when a user visited a route that required Authentication. If User is authenticated then go to the requested page or redirect to /login page. Once the user has successfully logged in redirect them back to the requested page. Vue Router has something called Navigation Guards to the rescue, that you can use as hook before every route or selected routes....

March 18, 2018 · 3 min · Harry Gill  |