title: Middleware using cookie nuxt
body: <p>I just setup middleware by checking cookie in nuxt but it's give me blank error, nothing error in console</p>
  
  <p><a href="https://i.stack.imgur.com/Mk1DS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mk1DS.png" alt="enter image description here"></a></p>
  
  <p>this is my middleware <code>authenticate.js</code></p>
  
  <pre><code>export default function({ store, redirect }) {
    const Cookie = process.client ? require('js-cookie') : undefined
    // If the user is not authenticated
    let token = Cookie.get('token')
    const userIsLoggedIn = token != null //cookie ada
    const userNeedLogin = token == null //cookie gak ada
    if (userNeedLogin) {
      return redirect('/login')
    }
    if (userIsLoggedIn) {
      return redirect('/dashboard')
    }
  }
  </code></pre>
  
  <p>and this is my nuxt.config.js</p>
  
  <pre><code>router: { 
      middleware: 'authenticate'
    }
  </code></pre>
  
  <p>it should redirect to page login when cookies is null but if cookie exist it redirect goes to dashboard, do i miss something ?</p>