-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The common.js file was being loaded and setting the default headers to use a Bearer token of null for all future requests (if a token did not exist in localStorage).
- Loading branch information
1 parent
014ffef
commit 4d25d4e
Showing
5 changed files
with
16 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import axios from 'axios'; | ||
import './common'; | ||
import './jwt'; | ||
import { | ||
FETCH_CHALLENGES, | ||
FETCH_REPOS, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
import axios from 'axios'; | ||
|
||
const jwt = window.localStorage.getItem('auth_token'); | ||
axios.defaults.headers.common.Authorization = `Bearer ${jwt}`; | ||
axios.defaults.baseURL = process.env.REACT_APP_API_URL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import axios from 'axios'; | ||
import './common'; | ||
|
||
axios.interceptors.request.use((config) => { | ||
const token = window.localStorage.getItem('auth_token'); | ||
|
||
if (token != null) { | ||
config.headers.Authorization = `Bearer ${token}`; // eslint-disable-line | ||
} | ||
|
||
return config; | ||
}, err => (Promise.reject(err))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import axios from 'axios'; | ||
import './common'; | ||
import './jwt'; | ||
import { | ||
FETCH_LEADERBOARD, | ||
NETWORK_ERROR, | ||
|