Skip to content

Commit

Permalink
Merge pull request #214 from rkshaon/212-call-every-api-with-token-if…
Browse files Browse the repository at this point in the history
…-token-is-available

done: #212 - now calling every API with token if token is available
  • Loading branch information
rkshaon authored Dec 17, 2024
2 parents 1c8ac7a + 3bf44ce commit 82521b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ echo -e "${YELLOW}=======================================${RESET}"
python manage.py migrate


echo -e "${BLUE}Restart Backend Gunicorn Service${RESET}"
echo -e "${BLUE}Restart Backend Services${RESET}"
echo -e "${YELLOW}=======================================${RESET}"
systemctl restart gunicorn-bookshelf.service
systemctl restart celery_bookshelf.service
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/services/axiosInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ const api = axios.create({
api.interceptors.request.use(
(config) => {
console.log('\nURL', config.url)
const token = getAccessToken()
if (config.requiresAuth) {
// Check for custom requiresAuth flag
const token = getAccessToken()
if (token) {
config.headers.Authorization = `Bearer ${token}`
}
} else {
if (token) {
config.headers.Authorization = `Bearer ${token}`
}
Expand Down

0 comments on commit 82521b0

Please sign in to comment.