title: *Nuxt JS Auth* Why after success login with loginWith in template sections auth.loggedIn is true, but in middleware file is false?
body: <p>I just started learning NuxtJS and I want to implement authentication by auth module for Nuxt.
  I don't know why, but login with loginWith seems working, on vue files I can get data about logged user and loggedIn variable has true value. But I noticed when I set middleware from auth module, even if I'm logged in, server is redirecting always to login endpoint. I saw that I can make my middleware file, but there loggedIn has value false, so I can't be redirected correctly.</p>
  
  <p><strong>index.vue</strong></p>
  
  <pre><code>&lt;template&gt;
      &lt;div id="main-page"&gt;
          &lt;panel /&gt;
      &lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
  import panel from "~/components/Panel.vue"
  
  
  export default {
      middleware: ['authenticated'],
      'components': {
          panel
      },
  
  };
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>My login component:</strong></p>
  
  <pre><code>&lt;template&gt;
      &lt;div id="form-wrapper"&gt;
          &lt;b-form-group 
              class="ml-3 mr-5"
              label="Username"
              label-for="id-username"
              :invalid-feedback="invalidFeedback"
              :state='state'
          &gt;
              &lt;b-form-input id="id-username" v-model="username" type="text" placeholder="elo"&gt;&lt;/b-form-input&gt;        
          &lt;/b-form-group&gt;
          &lt;b-form-group 
              class="ml-3 mr-5"
              label="Password"
              label-for="id-password"
              :invalid-feedback="invalidFeedbackPass"
              :state='statePass'
          &gt;
              &lt;b-form-input id="id-password" v-model="password" type="password"&gt;&lt;/b-form-input&gt;        
          &lt;/b-form-group&gt;
          &lt;b-button v-b-modal.login-modal class="ml-3 mr-5" variant="outline-success"&gt;Login&lt;/b-button&gt;
  &lt;div v-if="$auth.loggedIn"&gt;{{ $auth.loggedIn }}&lt;/div&gt; // here is true after login
  
          &lt;b-modal ref="login-modal" id="login-modal" hide-footer hide-header&gt;
              &lt;p&gt;Login: {{ username }} Hasło: {{ password }}&lt;/p&gt;
              &lt;b-button @click="loginUser({username, password})"&gt;Send&lt;/b-button&gt;
          &lt;/b-modal&gt;
      &lt;/div&gt;    
  &lt;/template&gt;
  
  &lt;script&gt;
  import "bootstrap-vue"
  import axios from "axios"
  
  export default {
      name: "loginForm",
      data() {
          return{
              username: '',
              password: '',
          }
      },
      props: {
  
      },
      methods: {
          async loginUser(loginInfo){
              try {
                  await this.$auth.loginWith('local', {
                      data: loginInfo
                  });
              } catch (e) {
                  this.$router.push('/');
              }
          }
  
      },
  ...
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>nuxt.config.js for auth</strong></p>
  
  <pre><code>auth: {
      strategies: {
        local: {
          endpoints: {
            login: { url: '/auth/token/login/', method: 'post', propertyName: 'auth_token' },
            logout: { url: '/auth/token/logout/', method: 'post' },
            user: { url: '/auth/users/me/', method: 'get', propertyName: false }
          },
          tokenRequired: true,
          tokenType: 'Token',
          tokenName: 'Authorization'
        }
      },
  
      redirect: {
        login: "/",
        logout: "/",
        home: "/home"
      },
  
    },
  </code></pre>
  
  <p><strong>autenticated.js in middleware</strong></p>
  
  <pre><code>export default function ({ store, redirect }) {
    console.log(store.state.auth.loggedIn); // here returns false, even after success login
    if (store.state.auth.loggedIn) {
      return redirect('/home')
    }
  }
  </code></pre>
  
  <p>Worth to mention is that, it's running on docker. Maybe that's a problem.</p>
  
  <p><strong>UPDATE</strong>
  I changed nuxt mode from SSR to SPA and now everything works from nuxt auth module.</p>
  
  <p>But I want to that works on SSR, so if someone have solution, please share.</p>