From 48a0e37080c4194acf4192d2401b20affdd2ee16 Mon Sep 17 00:00:00 2001 From: Facundo De Lorenzo Date: Thu, 16 May 2024 11:37:47 -0300 Subject: [PATCH] fix local debug of api with front --- .vscode/launch.json | 2 +- package.json | 3 ++- packages/api/package.json | 3 ++- packages/api/template.yaml | 2 +- packages/front/src/components/app/hooks/useGetProducts.ts | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index e3d2c28..5b944b0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,7 +7,7 @@ "name": "Debug challenge!", "runtimeExecutable": "concurrently", "runtimeArgs": [ - "pnpm --filter api start:debug", + "pnpm --filter api start", "pnpm --filter front start" ], "autoAttachChildProcesses": true, diff --git a/package.json b/package.json index 50e244b..1cbed91 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,9 @@ ] }, "scripts": { - "dev:frontapi": "concurrently \"pnpm --filter api start:debug\" \"pnpm --filter front start\"", + "dev:frontapi": "concurrently \"pnpm --filter api start\" \"pnpm --filter front start\"", "dev:front": "pnpm --filter front start", + "dev:api": "pnpm --filter api start", "build:front": "pnpm --filter front build" } } diff --git a/packages/api/package.json b/packages/api/package.json index 2d50521..70ed41b 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -7,7 +7,8 @@ "license": "UNLICENSED", "scripts": { "build": "rm -rf dist && tsc -b", - "postbuild": "cp package.json dist/package.json" + "postbuild": "cp package.json dist/package.json", + "start": "sam build && sam local start-api -p 5000" }, "devDependencies": { "@types/aws-lambda": "^8.10.137", diff --git a/packages/api/template.yaml b/packages/api/template.yaml index 7f78e27..471401f 100644 --- a/packages/api/template.yaml +++ b/packages/api/template.yaml @@ -18,7 +18,7 @@ Resources: Method: GET Path: /products - createOrderFunction: + CreateOrderFunction: Type: AWS::Serverless::Function Properties: CodeUri: ./dist diff --git a/packages/front/src/components/app/hooks/useGetProducts.ts b/packages/front/src/components/app/hooks/useGetProducts.ts index 43cf2d1..e23c543 100644 --- a/packages/front/src/components/app/hooks/useGetProducts.ts +++ b/packages/front/src/components/app/hooks/useGetProducts.ts @@ -10,7 +10,7 @@ const useGetProducts = () => { const [products, setProducts] = useState([]); useEffect(() => { - axios.get("http://localhost:5000/products").then((resp) => { + axios.get(`${process.env.REACT_APP_API_ENDPOINT}/products`).then((resp) => { if (resp.data) setProducts(resp.data); }); }, []);