Vuex not matching

This is regards to a Nuxt middleware.

I have a simple middleware called logged.js which basically says on the login page if your logged in redirect to users home page.

export default function({ store, redirect }) {
  console.log(store.state.authStore, 'fullstore') // this always shows logged in false
  // If the user is authenticated
  if (store.state.authStore.loggedIn === true) {
    console.log('logged in get out of here')
    return redirect(store.state.authStore.user.home)

Problem is this middleware always says loggedIn is false.
Console / cli shows :

{                                                                                                                                            18:08:16
  busy: false,
  loggedIn: false,
  user: {
    username: 'Default'

Yet dev tools and rest of the site read Vuex correct state as logged in.

I can hard refresh the page / F5 anywhere and the state is never lost until I actually logout then dev tools shows loggedIn: false but the middleware never seems to be correct when loggedIn.

If I login and get directed to user admin area, all is good. Logout and manually try to navigate back to any auth required area I get the boot as expected. Just on the login page it allows even if logged in to re-login. Not really a huge issue but still. If your logged in you should not reach a page to login.

I even made a button from inside an authenticated / logged in page when clicked is coded to take me to login page and the middleware prevents navigation to that page.

<v-btn round dark depressed class="z-action" :to="'/login'">
   Login test

But if i try manually type site/login path in the url no problem, middleware just seems to fall asleep and say ohh well.

It sounds like you have a race issue. I’m assuming the default loggedIn state is false, so when the app boots up and where ever you check the auth state to switch it to true happens after the middleware runs - which is why it works anytime that isn’t a refresh/direct hit to the url.