-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rely on authentication token stored in cookie (#817)
* chore: consume platform api on rewritten same domain path * feat: remove local storage usage * fix: make sure login state is known on first render * refactor: handle login state while app is being displayed * fix: initializing auth store should only ever happen once * chore: enable api proxying in netlify preview * chore: configure webpack dev server to proxy api * chore: normalize filenames * fix: proxy rule is overwritten
- Loading branch information
Showing
14 changed files
with
126 additions
and
85 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
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
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,33 +1,10 @@ | ||
/* global localStorage */ | ||
|
||
import Axios from 'axios' | ||
import config from '~/config' | ||
|
||
const axios = Axios.create({ | ||
baseURL: config.API_URL, | ||
baseURL: '/api', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}) | ||
|
||
/* | ||
* The interceptor here ensures that we check for the token in local storage | ||
* every time an ajax request is made | ||
*/ | ||
axios.interceptors.request.use( | ||
(config) => { | ||
const token = localStorage.getItem('auth') | ||
|
||
if (token) { | ||
config.headers.Authorization = `Bearer ${token}` | ||
} | ||
|
||
return config | ||
}, | ||
|
||
(error) => { | ||
return Promise.reject(error) | ||
} | ||
) | ||
|
||
export default axios |
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
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
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
Oops, something went wrong.