Closed WeyIin closed 6 years ago
Hi, have you used the search for 'x-access-token' among the source files of the project? I see 8 results in the frontend folder. I suppose they should be replaced to Authorization in your case. Does the 'Authorization' cookie exist after you log in?
Hey @Kasheftin :wave: Yeah, I used search for 'x-access-token' and none pop out, and if I search for Authorization, there are 8 results.
Yes, Authorization cookie exists when I log in, and even after refresh, that cookie remains set in my browser.
Since the cookie has to have 'Bearer
Can you notice %20 - space code instead of an actual space. You think that might be causing issues?
I had it like this:
utils/auth.js
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
store/auth.js
setAuthToken(response.data.token)
It didn't work but changing to:
utils/auth.js
axios.defaults.headers.common['Authorization'] = token
store/auth.js
setAuthToken('Bearer ' + response.data.token)
works! Weird but okay ^_^
Anyway, this issue is now solved and hopefully it is going to be helpful to other people being stuck at the same issue I've had.
Edit: %20 character instead of space does not change the behaviour, authorization works regardless, although it does NOT work in postman.
Since my back end expects Authorization Bearer token, I changed x-access-token to Authorization. Everything works fine but on refresh, token is lost and it logs me out.
What am I missing?
Help, please! :)