Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

jwt - @nuxt/auth ssr do not keep Authorization Bearer token after refresh

I'm trying to implement my own authentification system

For the front im using Nuxtjs, and the back Nestjs,

When im logging in, i receive my auth JWT, while i dont refresh the page or change current page there is no problem, but when i'm leaving current page and i request my backend there is no more Authorization headers with received JWT

that's my @nuxt/auth config:

  auth: {
    strategies: {
      local: {
        token: {
          property: 'access_token',
        },
        user: {
          property: 'user',
        },
        endpoints: {
          login: { url: '/api/auth/login', method: 'post' },
          logout: false,
          user: { url: '/api/auth/user', method: 'get' },
        },
      },
    },
  },

and my login function

async userLogin() {
      try {
        let response = await this.$auth.loginWith('local', { data: this.login })
        console.log(this.$auth.user)
      } catch (err) {}
    },

can someone help me ?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...