Skip to content

Token is stored with prefix in cookie and localstorage #113

Closed

Description

Version

v4.0.0

Reproduction link

https://nuxt-auth.herokuapp.com/

Steps to reproduce

  1. Login using "local" scheme.
  2. Check localstorage and cookies and you see the token with the prefix Bearer.
  3. Try to do a request with axios.
  4. The Authorization header will have 2 prefix and the token, ex: Bearer Bearer ........
  5. The request will fail beacause the authorization header is invalid.

What is expected ?

The token must be saved without the prefix because the setToken helper of axios module already set the prefix.

What is actually happening?

The token is saved with the prefix and all future request made by axios has an invalid authorization header.

  • The fetchUser method of the module has the correct authorization header because builds it own header, because of this the login process is okey, you can see this in /lib/auth/auth.js file line 251.

Additional comments?

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/

This bug report is available on Nuxt.js community (#c81)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions