feat: create auth
ci-front / build (push) Successful in 2m1s

This commit is contained in:
2026-04-04 01:43:25 +03:00
parent 57f12f792c
commit 065b5492ef
3 changed files with 60 additions and 41 deletions
+13
View File
@@ -32,6 +32,19 @@ class ApiClient {
private setupInterceptors(): void {
this.axiosInstance.interceptors.request.use(
(config: InternalAxiosRequestConfig): InternalAxiosRequestConfig => {
// Получаем токен из localStorage
const authStorage = localStorage.getItem("auth-storage");
if (authStorage) {
try {
const parsed = JSON.parse(authStorage);
const token = parsed.state?.token;
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
} catch (e) {
console.error("[Auth] Failed to parse auth storage:", e);
}
}
return config;
},
(error: AxiosError): Promise<AxiosError> => {