]> git.digitality.be Git - pdw25-26/commitdiff
Update (pas encore fini les modification)
authorThibaud Moustier <thibaudmoustier0@gmail.com>
Sat, 28 Feb 2026 17:08:30 +0000 (18:08 +0100)
committerThibaud Moustier <thibaudmoustier0@gmail.com>
Sat, 28 Feb 2026 17:08:30 +0000 (18:08 +0100)
Wallette/mobile/src/config/api.ts
Wallette/mobile/src/config/env.ts

index 19f8d94bb085920cad8d0c2f860c35d889279166..17e74187940eaed12b19e7c7c2263b1ca6786ddc 100644 (file)
@@ -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://<HOST>:3000/api/...
- * Socket.IO passe aussi via le gateway:
- *   http://<HOST>: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
index 4ffc47514416713d7b6e65636d843a878700720d..bd7d115acbbed4115e63df5e5cf9787ae19b14dc 100644 (file)
@@ -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   : <GATEWAY>/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 :