DEV Community

Discussion on: Secure authentication in Nuxt SPA with Laravel as back-end

Collapse
 
stefant123 profile image
StefanT123

Never save the token in the local storage, if you do, you are exposing your app to potential attacks. If you are using Nuxt.js, you should simply make plugin and put this

export default function ({store}) {
  window.onNuxtReady(() => {
    // refresh the token
  });
}

As stated in the Nuxt.js docs for the plugin:

Nuxt.js allows you to define JavaScript plugins to be run before instantiating the root Vue.js Application.

If you are using some other JS library, check their doocumentation and see how can you run some function before instantiating the root app.