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
* 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/...
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 :