diff --git a/README.md b/README.md index 4b54653..95182e1 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,13 @@ cp apps/api/.env.example apps/api/.env # Fichier .env pour le frontend web (configuration de l'URL API) cp apps/web/.env.example apps/web/.env + +# Fichier .env pour l'application mobile (configuration de l'URL API) +cp apps/mobile/.env.example apps/mobile/.env + +# Pour builder l'app mobile en production, créer également : +cp apps/mobile/.env.example apps/mobile/.env.production +# Puis éditer .env.production avec l'URL publique de votre API ``` ### Lancer le projet (développement) diff --git a/apps/mobile/.env.example b/apps/mobile/.env.example new file mode 100644 index 0000000..e2595f5 --- /dev/null +++ b/apps/mobile/.env.example @@ -0,0 +1,9 @@ +# Configuration API pour l'application mobile +# +# Pour développement local (.env) : utilisez votre IP locale +# EXPO_PUBLIC_API_URL=http://192.168.1.XXX:3000 +# +# Pour production (.env.production) : utilisez l'URL publique de votre API +# EXPO_PUBLIC_API_URL=https://api.dropit-app.fr + +EXPO_PUBLIC_API_URL=http://192.168.1.XXX:3000 diff --git a/apps/mobile/.gitignore b/apps/mobile/.gitignore index 954fc66..033e4a4 100644 --- a/apps/mobile/.gitignore +++ b/apps/mobile/.gitignore @@ -32,6 +32,8 @@ yarn-error.* # local env files .env*.local +.env +.env.production # typescript *.tsbuildinfo diff --git a/apps/mobile/eas.json b/apps/mobile/eas.json index af331fb..79e0699 100644 --- a/apps/mobile/eas.json +++ b/apps/mobile/eas.json @@ -9,7 +9,10 @@ "distribution": "internal" }, "preview": { - "distribution": "internal" + "distribution": "internal", + "env": { + "EXPO_PUBLIC_API_URL": "https://api.dropit-app.fr" + } }, "production": { "autoIncrement": true diff --git a/apps/mobile/src/lib/api.ts b/apps/mobile/src/lib/api.ts index 09843cf..7ae3f89 100644 --- a/apps/mobile/src/lib/api.ts +++ b/apps/mobile/src/lib/api.ts @@ -4,7 +4,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage'; // Client API pour React Native avec gestion du Bearer token export const api = initClient(apiContract, { - baseUrl: 'http://192.168.1.147:3000/api', + baseUrl: `${process.env.EXPO_PUBLIC_API_URL || 'http://192.168.1.147:3000'}/api`, // Configuration pour React Native // biome-ignore lint/suspicious/noExplicitAny: Better Auth type compatibility api: async (args: any) => { diff --git a/apps/mobile/src/lib/auth-client.ts b/apps/mobile/src/lib/auth-client.ts index 94eaa76..7767318 100644 --- a/apps/mobile/src/lib/auth-client.ts +++ b/apps/mobile/src/lib/auth-client.ts @@ -5,7 +5,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage'; // Configuration du client d'authentification pour React Native export const authClient = createAuthClient({ - baseURL: 'http://192.168.1.147:3000', // IP locale pour mobile + baseURL: process.env.EXPO_PUBLIC_API_URL || 'http://192.168.1.147:3000', plugins: [ organizationClient({ // biome-ignore lint/suspicious/noExplicitAny: Better Auth type compatibility