From c0c8e845eda79020c3846e8a690e07e8b2eea0fa Mon Sep 17 00:00:00 2001 From: codermehraj Date: Thu, 4 Apr 2024 08:21:21 +0600 Subject: [PATCH 1/3] Added Optional AWS backend connection info --- README.md | 8 ++++++++ client/components/dataTables/BillBySTSId.tsx | 5 +++-- client/data/apiRoutes.ts | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9214bed..a2fbaa3 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,14 @@ Go to the source directory and give the following command ```bash docker compose up --build ``` +## To run using AWS Backend (if docker compose fails) +Go to `client\data\apiRoutes` and comment the `first line` and uncomment the second +```js +export const baseUrl = "http://localhost:8585"; // Uncomment to run Locally +// export const baseUrl = "http://13.250.36.61/"; // Uncomment to run in AWS +``` +When running on AWS the frontend might face some slow network problems which can be fixed by switching speed from no thorttling to fast 3G. [You can check this video to see the demonstration of the problem mentioned here](https://drive.google.com/drive/folders/1B5N5o0ms7mizSYm5HNiAjJj0O82Zb1tq?usp=sharing). + ## License [MIT](https://choosealicense.com/licenses/mit/) diff --git a/client/components/dataTables/BillBySTSId.tsx b/client/components/dataTables/BillBySTSId.tsx index 904c402..f216104 100644 --- a/client/components/dataTables/BillBySTSId.tsx +++ b/client/components/dataTables/BillBySTSId.tsx @@ -17,6 +17,7 @@ import EmptyFillContainer from "../dashboard-componenets/cards/EmptyFillContaine import { getCookie } from "@/lib/cookieFunctions"; import { admin } from "@/data/roles"; import { Button } from "../ui/button"; +import { baseUrl } from "@/data/apiRoutes"; const dummyDataArray: ScheduleEntry[] = [ { @@ -97,7 +98,7 @@ export function BillBySTSId({ stsId, date }: { stsId: string; date: string }) { try { // fetch data from api const res: any = await axios.get( - "http://localhost:8585/schedules/search?date=" + + baseUrl + "/schedules/search?date=" + date + "&stsId=" + stsId, @@ -126,7 +127,7 @@ export function BillBySTSId({ stsId, date }: { stsId: string; date: string }) { try { // fetch data from api const res: any = await axios.post( - "http://localhost:8585/schedules/create/" + date, + baseUrl + "/schedules/create/" + date, { headers: { Authorization: `Bearer ${localStorage.getItem(jwtToken)}`, diff --git a/client/data/apiRoutes.ts b/client/data/apiRoutes.ts index 9ec7b32..b883bc1 100644 --- a/client/data/apiRoutes.ts +++ b/client/data/apiRoutes.ts @@ -1,4 +1,5 @@ -const baseUrl = "http://localhost:8585"; +export const baseUrl = "http://localhost:8585"; // Local +// export const baseUrl = "http://13.250.36.61/"; // AWS export const apiRoutes = { auth: { From 8777f4a75ef79626a34c9445c4c631358a15ed4a Mon Sep 17 00:00:00 2001 From: Shawon Majid Date: Thu, 4 Apr 2024 14:34:08 +0600 Subject: [PATCH 2/3] Update apiRoutes.ts --- client/data/apiRoutes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/data/apiRoutes.ts b/client/data/apiRoutes.ts index b883bc1..10610f5 100644 --- a/client/data/apiRoutes.ts +++ b/client/data/apiRoutes.ts @@ -1,5 +1,5 @@ export const baseUrl = "http://localhost:8585"; // Local -// export const baseUrl = "http://13.250.36.61/"; // AWS +// export const baseUrl = "http://13.250.36.61"; // AWS export const apiRoutes = { auth: { From 01cc50fdaf1ef2262364009d9f2ba376aa6ee185 Mon Sep 17 00:00:00 2001 From: Shawon Majid Date: Thu, 4 Apr 2024 14:36:33 +0600 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a2fbaa3..2299792 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ docker compose up --build Go to `client\data\apiRoutes` and comment the `first line` and uncomment the second ```js export const baseUrl = "http://localhost:8585"; // Uncomment to run Locally -// export const baseUrl = "http://13.250.36.61/"; // Uncomment to run in AWS +// export const baseUrl = "http://13.250.36.61"; // Uncomment to run in AWS ``` When running on AWS the frontend might face some slow network problems which can be fixed by switching speed from no thorttling to fast 3G. [You can check this video to see the demonstration of the problem mentioned here](https://drive.google.com/drive/folders/1B5N5o0ms7mizSYm5HNiAjJj0O82Zb1tq?usp=sharing).