302 Found redirect

hasanmumin
0
hasanmumin
commented 2 months ago

Hello,
I just implemented auth-module with below configurations
// nuxt.config.js

router: {
middleware: ['auth']
},
auth: {
localStorage: false,
cookie: {
prefix: 'auth.',
options: {
path: '/',
expires: 30
}
},
redirect: {
login: '/login',
logout: '/',
callback: '/',
home: '/'
},
strategies: {
local: {
endpoints: {
login: {
url: 'login',
method: 'POST',
propertyName: 'token'
},
user: {
url: 'me',
method: 'GET'
},
logout: false
}
}
}
}

// login.vue

async login() {
try {
await this.$auth.loginWith('local', {
data: {
username: this.username,
password: this.password
}
})

    this.$router.push({ path: '/' })
  } catch (e) {
    this.error = e.response.message
  }
}

login working fine also it is setting cookie.

But when I try to go to
http://localhost:3000/secure

Headers:

Request URL: http://localhost:3000/secure
Request Method: GET
Status Code: 302 Found
Remote Address: 127.0.0.1:3000
Referrer Policy: no-referrer-when-downgrade

it is still redirecting login page.
I already follow like 5 times https://auth.nuxtjs.org/

But I could not fix. What is wrong with configuration ?
Can you help me ?

0
Informations
Question โ€ข Unresolved
#c280 - Created 2 months ago