https://nuxt-auth.herokuapp.com/
The token must be saved without the prefix because the setToken helper of axios module already set the prefix.
The token is saved with the prefix and all future request made by axios has an invalid authorization header.
You can see this issue in the demo site, check the localstorage "auth._token.local" key after login and "auth._token.local" cookie:
https://nuxt-auth.herokuapp.com/
@javialon26 Hi !
Thank you for your bug report, confirmed as a bug on the demo site using the following command while logged in:
$nuxt.$axios.get('api/auth/user');
This will automatically returns the following:
UnauthorizedError: Format is Authorization: Bearer [token]
As the request headers are composed by an invalid Authorization header:
Authorization: Bearer Bearer token
This is most likely related to this, I think the token is passed with "Bearer " and then set again with axios-module with this.$auth.ctx.app.$axios.setToken(token, this.options.tokenType)
"Bearer" is set by this on lib/core/auth.js here:
setToken (strategy, token) {
const _key = this.options.token.prefix + strategy
return this.$storage.setUniversal(_key, token)
}
Fixed on #115 - Will be available soon 👍
Wait for updates。。。。How I delete the prefix
Most helpful comment
@javialon26 Hi !
Thank you for your bug report, confirmed as a bug on the demo site using the following command while logged in:
This will automatically returns the following:
As the request headers are composed by an invalid Authorization header:
This is most likely related to this, I think the token is passed with "Bearer " and then set again with axios-module with
this.$auth.ctx.app.$axios.setToken(token, this.options.tokenType)"Bearer" is set by this on
lib/core/auth.jshere: