0

I'm creating an app using nuxt (2.15.8) and i'm using the @nuxtjs/auth (4.9.1) for authentication. I use local strategy to login users

auth: {
    redirect: {
      login: '/login',
      logout: false,
      home: false
    },
    strategies: {
      local: {
        endpoints: {
          login: {
            url: 'api/login',
            method: 'post',
            propertyName: 'token'
          },
          user: {
            url: 'api/user/fetch-logged-in',
            method: 'get',
            propertyName: false
          }
        },
        tokenType: ''
      }
    }
  }

While working locally, the users can login/logout without any problems. Once you log in, you can refresh the page and you stay logged-in which is exactly what I want.

The problem occurs on the staging server. I can login without any problems, but as soon as i refresh the page, I am automatically logged out and brought to the login page.

What's also strange is that when that happens, the auth._token.local in the cookies and the local storage is not empty, I can still see the token but i have to login again.

gogo_rulez
  • 389
  • 2
  • 10
  • 24
  • What is you build locally and try again? (to kinda emulate the staging server) – kissu Oct 14 '21 at 12:34
  • I have a simliar situation. I am using static hosting on netlify. User gets logged out on refresh, even though the cookie is still there – Sharkfin Jan 27 '22 at 20:30

0 Answers0