diff --git a/apps/mobile/app/login.tsx b/apps/mobile/app/login.tsx index 0c1df4c..947a171 100644 --- a/apps/mobile/app/login.tsx +++ b/apps/mobile/app/login.tsx @@ -1,5 +1,5 @@ import { useState } from "react"; -import { View, Text, TextInput, TouchableOpacity, StyleSheet, ActivityIndicator } from "react-native"; +import { View, Text, TextInput, TouchableOpacity, StyleSheet, ActivityIndicator, Platform } from "react-native"; import { router } from "expo-router"; import { setServerUrl, @@ -9,9 +9,11 @@ import { } from "../lib/server-config"; import { login } from "../lib/auth"; +const DEV_HOST = Platform.OS === "android" ? "10.0.2.2" : "localhost"; + export default function LoginScreen() { const [serverUrl, setServerUrlState] = useState( - __DEV__ ? "http://localhost:3000" : "https://trails.cool", + __DEV__ ? `http://${DEV_HOST}:3000` : "https://trails.cool", ); const [showCustomServer, setShowCustomServer] = useState(false); const [loading, setLoading] = useState(false); diff --git a/apps/mobile/lib/server-config.ts b/apps/mobile/lib/server-config.ts index a25c3d0..e7dc78b 100644 --- a/apps/mobile/lib/server-config.ts +++ b/apps/mobile/lib/server-config.ts @@ -1,8 +1,10 @@ +import { Platform } from "react-native"; import * as SecureStore from "expo-secure-store"; import { API_VERSION } from "@trails-cool/api"; const STORE_KEY_SERVER_URL = "server_url"; -const DEFAULT_SERVER_URL = __DEV__ ? "http://localhost:3000" : "https://trails.cool"; +const DEV_HOST = Platform.OS === "android" ? "10.0.2.2" : "localhost"; +const DEFAULT_SERVER_URL = __DEV__ ? `http://${DEV_HOST}:3000` : "https://trails.cool"; export interface DiscoveryResponse { apiVersion: string;