Home

Issue: 434

Middleware not running when accessing page directly

[issue link]

I have a login page with some middleware on it:

<template>
  <div>
    Hello login <nuxt-link to="/">Home Page</nuxt-link>
  </div>
</template>

<script>
  export default {
    middleware: 'authenticated'
  }
</script>

The middleware runs successfully when navigating to the login page through a nuxt-link.
However if I go directly to the /login page, not through a nuxt-link, the middleware doesn’t run.
This bug invalidates the use of middleware, since it won’t run if users access pages directly.

This question is available on Nuxt.js community (#c378)