From 3a459acf5f3e089b20c8b02d044231629109339a Mon Sep 17 00:00:00 2001 From: Bryan Silva Date: Sat, 18 May 2024 18:30:01 -0700 Subject: [PATCH] Fixed android localhost issue --- apps/expo/src/utils/api.tsx | 6 ++++++ apps/server/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/expo/src/utils/api.tsx b/apps/expo/src/utils/api.tsx index 39df5347..972f7297 100644 --- a/apps/expo/src/utils/api.tsx +++ b/apps/expo/src/utils/api.tsx @@ -1,4 +1,5 @@ import { useState } from "react"; +import { Platform } from "react-native"; import Constants from "expo-constants"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { httpBatchLink, loggerLink } from "@trpc/client"; @@ -35,6 +36,11 @@ const getBaseUrl = () => { "Failed to get localhost. Please point to your production server.", ); } + + if (Platform.OS == "android") { + return `http://10.0.2.2:3000`; + } + return `http://localhost:3000`; }; diff --git a/apps/server/package.json b/apps/server/package.json index 2794481a..c0b20c62 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -6,7 +6,7 @@ "scripts": { "clean": "rm -rf .turbo node_modules", "with-env": "dotenv -e ../../.env -- ", - "dev": "pnpm with-env sls offline --noPrependStageInUrl", + "dev": "pnpm with-env sls offline --noPrependStageInUrl --host 127.0.0.1", "deploy": "pnpm with-env AWS_PROFILE=icssc sls deploy --stage production", "test:daily": "pnpm with-env sls invoke local --function updateDaily | pino-pretty", "test:weekly": "pnpm with-env sls invoke local --function getWeekly | pino-pretty"