Auth provider added to the project
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { getAccessToken } from '@/features/authorization/api/identityAPI';
|
||||
import { ACCESS_TOKEN_KEY } from '@/providers/AuthProvider';
|
||||
import axios from 'axios';
|
||||
|
||||
const apiClient = axios.create({
|
||||
@@ -18,8 +18,8 @@ const apiClient = axios.create({
|
||||
// --- Request Interceptor ---
|
||||
// This runs BEFORE each request is sent
|
||||
apiClient.interceptors.request.use(
|
||||
async (config) => {
|
||||
const token = await getAccessToken();
|
||||
(config) => {
|
||||
const token = sessionStorage.getItem(ACCESS_TOKEN_KEY);
|
||||
if (token) {
|
||||
// Add the authorization token to the headers
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
|
||||
Reference in New Issue
Block a user