Should this module be setting my auth-token on all Axios requests. once set? If so, for some reason my token is not set on subsequent requests (It works fine for the login & login_check).
Or do I need to set this myself. If setting it myself, how is best advised for getting access to the token from within a plugin eg this is how I thought, but it does not work:
import axios from 'axios'
export default axios.create({
headers: {'Authorization': 'Bearer ' + this.$state.auth.token} //--> Cannot read property 'auth' of undefined
baseURL: 'http://localhost:8000'
})
@BonnieDoug Could you tell me what is the content of this.$state.auth and this.$auth.state ?
@breakingrobot
In a view compoent this.$state.auth results in:

From within a view component this.$auth.state results in:
<template>
<v-layout>
<pre>{{ this.$auth.state }}</pre>
</v-layout>
</template>
{
"user": {
"id": 61415,
"contact": 409983,
"client": {
"id": 4218,
"name": "Demonstration"
},
"forename": "Bob",
"surname": "Jones",
"company": "Bob and Sons Ltd"
},
"loggedIn": true
}
{
"user": null,
"loggedIn": false
}
Which is all as I would expect. I'm just surprised all subsequent requests to the backend don't have the header set. On the login_check & user_check the token is correctly set:
Authorization: Bearer removed_head.eyJyb2xlcyI6WyJST0xFX1VTRVIiXSwidXNlcm5hbWUiOjQzODEwLCJpYXQiOjE1MTg2MDM0NjcsImV4cCI6MTU1NDYwMzQ2N30.removed_sig
Also, all refresh requests (SSR) show the token is set in the Cookie request header, but these do not get set when requesting from the backend (I get 401 errors from my backend)
Which axios instance are you using for your requests? You should be using this.$axios to benefit from the headers set by auth-module.
@paulgv, Massive thank you. I wasn't aware this.$axios existed. All sorted now :)
Most helpful comment
Which axios instance are you using for your requests? You should be using
this.$axiosto benefit from the headers set by auth-module.