chore: fix url api

This commit is contained in:
2026-02-18 21:10:05 +01:00
parent 0c3809ddfb
commit c5b67674fc
4 changed files with 31 additions and 32 deletions
+3 -3
View File
@@ -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 {
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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
+11 -12
View File
@@ -1,27 +1,26 @@
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',
"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/');
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}`;
@@ -34,10 +33,10 @@ apiClient.interceptors.response.use(
(response) => response,
(error) => {
if (error.response?.status === 401) {
console.log('Session expirée');
console.log("Session expirée");
}
return Promise.reject(error);
}
},
);
export default apiClient;