Skip to content

Commit

Permalink
fix: api config
Browse files Browse the repository at this point in the history
  • Loading branch information
TomatoVan committed Feb 7, 2024
1 parent 1671965 commit aab3556
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/shared/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { USER_LOCALSTORAGE_KEY } from 'shared/const/localstorage';

export const $api = axios.create({
baseURL: __API__,
headers: {
authorization: localStorage.getItem(USER_LOCALSTORAGE_KEY) || '',
},
});

$api.interceptors.request.use((config) => {
if (config.headers) {
config.headers.Authorization = localStorage.getItem(USER_LOCALSTORAGE_KEY) || '';
}
return config;
});

0 comments on commit aab3556

Please sign in to comment.