From aab35560d3617501129324fe3ced9b58b1b70195 Mon Sep 17 00:00:00 2001 From: "Leon.kov" Date: Wed, 7 Feb 2024 17:59:45 +0300 Subject: [PATCH] fix: api config --- src/shared/api/api.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/shared/api/api.ts b/src/shared/api/api.ts index 0e1f2c6..526dded 100644 --- a/src/shared/api/api.ts +++ b/src/shared/api/api.ts @@ -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; });