I am setting up JWT authentication, everything is working fine but I got stuck at the last piece where I am not sure what I should do.
I have set up my Axios Config as this:
const token = ""
export const axios = Axios.create({
baseURL: "http://localhost:8080",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
},
});
so here are few problems I have ..
hope anyone can help me out! :)
For anyone coming accross this question, to handle such situations i use axios.interceptors which let you access a certain event inbetween the request and response, that way you can handle the Auth Token and also in case of the "need" to refresh the token, it also should be handled here.
Multiple Axios Configs are also a way to go, but not necessary for that case, pointing out here.