Skip to content

Commit

Permalink
Fixed android localhost issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bjsilva1 committed May 19, 2024
1 parent 8055761 commit 3a459ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions apps/expo/src/utils/api.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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`;
};

Expand Down
2 changes: 1 addition & 1 deletion apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 3a459ac

Please sign in to comment.