0
votes

I'm using Nuxt and the Auth module. I'm trying to redirect users to a login page when they aren't logged in.

nuxt.config.js:

auth: {
  redirect: {
    login: '/account/inloggen',
    logout: '/account/uitloggen',
    callback: '/account/aanmelden',
    home: '/'
  },
  strategies: {
    google: {
      access_token_endpoint: '****/social?identityProvider=Google',
      access_type: 'offline',
      client_id: '*****.apps.googleusercontent.com',
      grant_type: 'authorization_code',
      redirect_uri: 'http://localhost:3000/account/aanmelden',
      response_type: 'code',
      token_key: 'jwt',
      userinfo_endpoint: '****/user/profile'
    }
  },
  cookie: {
    options: {
      maxAge: 86400
    }
  }
  // localStorage: false
},

I'm reading the docs

login: User will be redirected to this path if login is required.

But I can't find where/how I require a user to log in.

The home: '/' redirect does work, when the user logs in they get redirected to the root of the app.

1

1 Answers

0
votes

Found my answer on Github

I've ran into this issue as well. My mistake was having auth: false set on my login page. If you have it, just remove it.

<script>
export default {
  auth: false
}
</script>