Auth provider added to the project

This commit is contained in:
مهرزاد قدرتی
2025-08-16 15:42:58 +03:30
parent 0548118208
commit 8a41aad9b9
10 changed files with 165 additions and 85 deletions

View File

@@ -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}`;