Static GitHub Issues

[825] Middleware is not working in header component

prev: Add lang attribute to html wrapper
next: issue with the offline plugin with CDN

I have some component which is App-Header and i need to check auth in it, so i'm using middleware for this. It's working on page, but there is no any reaction in this Header component.

This is middleware, running from nuxt-config:

import { getUser } from './../api/AuthService'

export default function ({ store }) {
  const user = getUser()
  user ? store.commit('SET_USER', user) : null
}

just checking cookie and set store object depend on it.

In Header component i'm trying to get info about authenticated user by catching the isAuthenticated getter:

data () {
  return {
    isAuthenticated: this.$store.getters.isAuthenticated
  }
},

Can anybody help or explain why it's not working? Is middleware is not corresponding with layout components?

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c709">#c709</a>)</em></sub></div>