From c5b67674fc6328bbf9aa337f59298d9b2f50a085 Mon Sep 17 00:00:00 2001 From: Xor290 Date: Wed, 18 Feb 2026 21:10:05 +0100 Subject: [PATCH] chore: fix url api --- frontend-admin/src/api/api_admin.ts | 6 +-- frontend-admin/src/api/api_cabine.ts | 4 +- frontend-admin/src/api/api_delivery.ts | 2 +- frontend-admin/src/api/client.ts | 51 +++++++++++++------------- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/frontend-admin/src/api/api_admin.ts b/frontend-admin/src/api/api_admin.ts index e0b02972..e1321146 100644 --- a/frontend-admin/src/api/api_admin.ts +++ b/frontend-admin/src/api/api_admin.ts @@ -9,8 +9,8 @@ import type { Alert, } from "./types"; -const V2 = "http://172.20.167.237:8080/api/v2"; -const CABINE_URL = "http://172.20.167.237:8080/api/v1/cabine"; +const V2 = "https://uber-stup.club/api/v2"; +const CABINE_URL = "https://uber-stup.club/api/v1/cabine"; // ============================================ // AUTH @@ -378,7 +378,7 @@ export const createClientByAdmin = async (data: { telephone: string; }) => { const { data: res } = await apiClient.post( - `http://172.20.167.237:8080/api/v1/auth/register`, + `https://uber-stup.club/api/v1/auth/register`, data, ); return { diff --git a/frontend-admin/src/api/api_cabine.ts b/frontend-admin/src/api/api_cabine.ts index 70a1daef..f531e4eb 100644 --- a/frontend-admin/src/api/api_cabine.ts +++ b/frontend-admin/src/api/api_cabine.ts @@ -6,8 +6,8 @@ import type { Alert, } from "./types"; -const API = "http://172.20.167.237:8080/api/v1/cabine"; -const V2 = "http://172.20.167.237:8080/api/v2"; +const API = "https://uber-stup.club/api/v1/cabine"; +const V2 = "https://uber-stup.club/api/v2"; // ============================================ // ITEMS diff --git a/frontend-admin/src/api/api_delivery.ts b/frontend-admin/src/api/api_delivery.ts index 69f6756d..7d775388 100644 --- a/frontend-admin/src/api/api_delivery.ts +++ b/frontend-admin/src/api/api_delivery.ts @@ -7,7 +7,7 @@ import type { Alert, } from "./types"; -const API = "http://172.20.167.237:8080/api/v1/livreur"; +const API = "https://uber-stup.club/api/v1/livreur"; // ============================================ // STATUT diff --git a/frontend-admin/src/api/client.ts b/frontend-admin/src/api/client.ts index 7a843149..d75a799d 100644 --- a/frontend-admin/src/api/client.ts +++ b/frontend-admin/src/api/client.ts @@ -1,43 +1,42 @@ -import axios from 'axios'; -import { getToken, getAdminToken } from '../auth/tokenStorage'; +import axios from "axios"; +import { getToken, getAdminToken } from "../auth/tokenStorage"; // Change this to your server IP/domain -export const API_BASE_URL = 'http://localhost:8080'; +export const API_BASE_URL = "https://uber-stup.club"; const apiClient = axios.create({ - baseURL: API_BASE_URL, - timeout: 15000, - headers: { - 'Content-Type': 'application/json', - }, + baseURL: API_BASE_URL, + timeout: 15000, + headers: { + "Content-Type": "application/json", + }, }); // Request interceptor: attach JWT token apiClient.interceptors.request.use(async (config) => { - // Determine which token to use based on URL - const isAdminRoute = config.url?.includes('/api/v2/') || - config.url?.includes('/api/v1/cabine/') || - config.url?.includes('/api/v1/livreur/'); + // Determine which token to use based on URL + const isAdminRoute = + config.url?.includes("/api/v2/") || + config.url?.includes("/api/v1/cabine/") || + config.url?.includes("/api/v1/livreur/"); - const token = isAdminRoute - ? await getAdminToken() - : await getToken(); + const token = isAdminRoute ? await getAdminToken() : await getToken(); - if (token) { - config.headers.Authorization = `Bearer ${token}`; - } - return config; + if (token) { + config.headers.Authorization = `Bearer ${token}`; + } + return config; }); // Response interceptor: handle common errors apiClient.interceptors.response.use( - (response) => response, - (error) => { - if (error.response?.status === 401) { - console.log('Session expirée'); - } - return Promise.reject(error); - } + (response) => response, + (error) => { + if (error.response?.status === 401) { + console.log("Session expirée"); + } + return Promise.reject(error); + }, ); export default apiClient;