VladimirMikulic's solution to "Need help with Nuxt.js and Nuxt-Auth"

Possible Solution<\/h1>\n\n

Hello,<\/p>\n\n

I don't have a full environment (back-end code) to reproduce the issue, but from what I was able to gather from this thread<\/a>, you could create custom auth reset functionality in plugins/axios.js<\/code>. Something like this<\/a>.<\/p>\n\n

Let me know how it worked.<\/p>\n\n

Thank you,
\nVladimir<\/p>\n

# Possible Solution Hello, I don't have a full environment (back-end code) to reproduce the issue, but from what I was able to gather from this [thread](https://github.com/nuxt-community/auth-module/issues/424), you could create custom auth reset functionality in `plugins/axios.js`. Something like [this](https://github.com/nuxt-community/auth-module/issues/424#issuecomment-576049308). Let). ### The menext knowstep Create howa file `middleware/authenticated.js` Put [this](https://paste.ofcode.org/zaycLcq6kYWysNYdbQgqWu) code in the middleware. Set ``` router: { middleware: [ "authenticated" ] }, ``` in `nuxt.config.js`. (router entry already exists, just modify it worked. Thankto include authenticated `middleware`) This will make our middleware run before every route and check if the user is authenticated. If it's not, then it will redirect the user to `/login`. Thank you, Vladimir
# Possible Solution Hello, I don't have a full environment (back-end code) to reproduce the issue, but from what I was able to gather from this [thread](https://github.com/nuxt-community/auth-module/issues/424), you could create custom auth reset functionality in `plugins/axios.js`. Something like [this](https://github.com/nuxt-community/auth-module/issues/424#issuecomment-576049308). ### The next step Create a file `middleware/authenticated.js` Put [this](https://paste.ofcode.org/zaycLcq6kYWysNYdbQgqWuwneK4drPsmNVJxzCWRNtuA) code in the middleware. Set ``` router: { middleware: [ "authenticated" ] }, ``` in `nuxt.config.js`. (router entry already exists, just modify it to include authenticated `middleware`) This will make our middleware run before every route and check if the user is authenticated. If it's not, then it will redirect the user to `/login`. Thank you, Vladimir
# Possible Solution Hello, I don't have a full environment (back-end code) to reproduce the issue, but from what I was able to gather from this [thread](https://github.com/nuxt-community/auth-module/issues/424), you could create custom auth reset functionality in `plugins/axios.js`. Something like [this](https://github.com/nuxt-community/auth-module/issues/424#issuecomment-576049308). ### The next step Create a file `middleware/authenticated.js` Put [this](https://paste.ofcode.org/wneK4drPsmNVJxzCWRNtuA) code in the middleware. Set ``` router: { middleware: [ "authenticated" ] }, ``` in `nuxt.config.js`. (router entry already exists, just modify it to include authenticated `middleware`) This will make our middleware run before every route and check if the user is authenticated. Ifstill it'slogged not, thenin (valid itsession). Thank will redirect the user to `/login`. Thank you, Vladimir
# Possible Solution Hello, I don't have a full environment (back-end code) to reproduce the issue, but from what I was able to gather from this [thread](https://github.com/nuxt-community/auth-module/issues/424), you could create custom auth reset functionality in `plugins/axios.js`. Something like [this](https://github.com/nuxt-community/auth-module/issues/424#issuecomment-576049308). ### The next step Create a file `middleware/authenticated.js` Put [this](https://paste.ofcode.org/wneK4drPsmNVJxzCWRNtuAr8DyxMg32J9RXk4JW3sf9D) code in the middleware. Set ``` router: { middleware: [ "authenticated" ] }, ``` in `nuxt.config.js`. (router entry already exists, just modify it to include authenticated `middleware`) This will make our middleware run before every route and check if the user is still logged in (valid session). Thank you, Vladimir

User: VladimirMikulic

Question: Need help with Nuxt.js and Nuxt-Auth

Back to question