From: Thibaud Moustier Date: Sat, 28 Feb 2026 17:08:30 +0000 (+0100) Subject: Update (pas encore fini les modification) X-Git-Url: https://git.digitality.be/?a=commitdiff_plain;h=44c91bbe5e0a74c9ea72402311999ebaf9e58d5b;p=pdw25-26 Update (pas encore fini les modification) --- diff --git a/Wallette/mobile/src/config/api.ts b/Wallette/mobile/src/config/api.ts index 19f8d94..17e7418 100644 --- a/Wallette/mobile/src/config/api.ts +++ b/Wallette/mobile/src/config/api.ts @@ -1,41 +1,32 @@ import { Platform } from "react-native"; +import { API_BASE_URL, SERVER_URL, ENV_MODE, PLATFORM } from "./env"; /** - * API Gateway (microservices) - * --------------------------- - * - Téléphone physique : utiliser l'IP du PC sur le réseau local - * - Android émulateur : 10.0.2.2 - * - iOS simulateur : localhost (souvent OK) + * gatewayUrls.ts (ou apiConfig.ts) + * ------------------------------- + * Source de vérité = env.ts * - * IMPORTANT : le mobile doit appeler UNIQUEMENT le gateway: - * http://:3000/api/... - * Socket.IO passe aussi via le gateway: - * http://:3000 (proxy /socket.io/*) + * - REST : API_BASE_URL (déjà contient /api) + * - Socket : SERVER_URL (gateway root, sans /api) + * + * NOTE : + * - En DEV, env.ts pointe vers ton gateway local (http://IP:3000) + * - En PROD, env.ts pointe vers duckdns (https://wallette.duckdns.org) */ -// ✅ Change uniquement cette valeur pour ton PC -const DEV_LAN_IP = "192.168.129.121"; - -export function getGatewayHost(): string { - if (__DEV__) { - // Téléphone physique / LAN - return DEV_LAN_IP; - } - // En prod (ou build), tu mettras un vrai domaine/IP si nécessaire - return DEV_LAN_IP; -} - -export function getGatewayBaseUrl(): string { - const host = - Platform.OS === "android" && !__DEV__ - ? "10.0.2.2" - : getGatewayHost(); +// REST (via gateway) +export const REST_BASE_URL = API_BASE_URL; - return `http://${host}:3000`; -} +// Socket.IO (via gateway) +export const SOCKET_BASE_URL = SERVER_URL; -// REST base -export const API_BASE_URL = `${getGatewayBaseUrl()}/api`; - -// Socket base (pas /api) -export const SOCKET_BASE_URL = `${getGatewayBaseUrl()}`; \ No newline at end of file +/** + * Debug helper : pratique pour afficher dans un screen "About / Debug" + */ +export const DEBUG_NETWORK_INFO = { + env: ENV_MODE, + platform: PLATFORM, + rest: REST_BASE_URL, + socket: SOCKET_BASE_URL, + rnPlatform: Platform.OS, +}; \ No newline at end of file diff --git a/Wallette/mobile/src/config/env.ts b/Wallette/mobile/src/config/env.ts index 4ffc475..bd7d115 100644 --- a/Wallette/mobile/src/config/env.ts +++ b/Wallette/mobile/src/config/env.ts @@ -6,7 +6,7 @@ import { Platform } from "react-native"; * Objectif : 1 seul point de config réseau. * * DEV : IP LAN (PC qui fait tourner gateway en local) - * PROD : URL publique (serveur prof / déploiement) + * PROD : URL publique (duckdns / serveur) * * Le mobile parle UNIQUEMENT au Gateway : * - REST : /api/... @@ -17,12 +17,8 @@ import { Platform } from "react-native"; const DEV_LAN_IP = "192.168.129.121"; const DEV_GATEWAY = `http://${DEV_LAN_IP}:3000`; -// ✅ PROD (quand le chef vous donne l’URL du serveur prof) -// Mets un placeholder clair pour ne pas oublier -const PROD_GATEWAY = "https://CHANGE_ME_GATEWAY_URL"; - -// Si tu veux autoriser un PROD en http (pas recommandé iOS), tu peux. -// const PROD_GATEWAY = "http://CHANGE_ME_GATEWAY_URL:3000"; +// ✅ PROD (duckdns) +const PROD_GATEWAY = "https://wallette.duckdns.org"; /** * Pour l'instant :