Static GitHub Issues

[3208] middleware on page-reload is not called on process.client

prev: support nuxt organization by filename rather than directory name
next: Build with sass-loader (SCSS) on production

What problem does this feature solve?

I placed a middleware on a page like:

export default{
 middleware:['isAuth']
}

and this is the middleware code

export default function ({store, redirect}) {
  console.log(process.client) => never called on page-reload
  if (!store.getters.canEdit && process.client) {
    return redirect('/')
  }
}

This middleware works if I route to pages which are connected to the middleware. But if I do a page-reload on a page then the code is only getting executed on the server. Is this a bug or by design?

What does the proposed changes look like?

The middleware should execute always client and server side - either on page reload or routing.

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