bertho-zero / react-redux-universal-hot-example

A starter boilerplate for a universal webapp using react, redux, express and feathers
https://react-hot-example.herokuapp.com/
MIT License
635 stars 171 forks source link

Failing to send authentication credentials to custom API #561

Closed S1MB10T3 closed 5 years ago

S1MB10T3 commented 5 years ago

How should I send over the token that's saved in my cookies over to axios. Tried changing apiClient.js token to token = cookie.get('jwt'). Still doesn't get sent over along with a post request and getting a 403 error "Authentication credentials were not provided." in response.

S1MB10T3 commented 5 years ago

Found a solution. If the user refreshes the page the will header loses the authorization token after login. Need to remake load() action to work with my api. For now I'm letting token in apiClient.js initialize with the jwt token cookie.

Also changed the header to add to work with Django restframework by adding

if (token) {
    conf.headers.authorization = `Bearer ${token}`;
}