dimanche 22 juillet 2018

Auth state not maintained after page refresh

I'm using Nuxt and the Auth module to create a simple pwa hosted on S3 and delivered via CloudFront. I managed to create a custom strategy to log users in from my Laravel based API using Passport & Password Grants.

auth: {
    redirect: {
      //stuff
    },
    strategies: {
      local: false,
      password_grant_custom: {
        _scheme: "~/auth/schemes/PassportPasswordScheme.js",
        client_id: process.env.PASSPORT_PASSWORD_GRANT_ID,
        client_secret: process.env.PASSPORT_PASSWORD_GRANT_SECRET,
        endpoints: {
          login: {
            url: "/oauth/token",
            method: "post",
            propertyName: "access_token"
          },
          logout: false,
          user: {
            url: "api/v1/me",
            method: 'get',
            propertyName: false
          }
        }
      }
    }
  },

I'm able to log in without a problem, but upon refresh I'm logged out again. This happens only on the live/dist version of the pwa after running npm run generate. When running in Dev, upon refresh the user is still logged in.

How do I keep the user logged in after refresh?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire