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

Failing to send authentication credentials to custom API

Closed this issue · 1 comments

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.

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}`;
}