From 509a79152ee00aa4e0bb356c2fc3103bfa8e46d6 Mon Sep 17 00:00:00 2001 From: iamtrazy Date: Thu, 18 Jul 2024 19:08:39 +0530 Subject: [PATCH] fix: .env fixes for deployment --- src/components/User/AllFoodItems/index.tsx | 3 ++- src/components/User/FoodItem/index.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/User/AllFoodItems/index.tsx b/src/components/User/AllFoodItems/index.tsx index 3a8874f..e83d3d0 100644 --- a/src/components/User/AllFoodItems/index.tsx +++ b/src/components/User/AllFoodItems/index.tsx @@ -9,7 +9,8 @@ function index() { const fetchItems = async () => { try { - const response = await fetch('http://localhost:8080/api/lafresca/food'); + let apiUrl = (import.meta as any).env.VITE_API_URL; + const response = await fetch(`${apiUrl}/food`); if (!response.ok) { throw new Error('Failed to fetch item'); } diff --git a/src/components/User/FoodItem/index.tsx b/src/components/User/FoodItem/index.tsx index ccc9ab1..e48ff2a 100644 --- a/src/components/User/FoodItem/index.tsx +++ b/src/components/User/FoodItem/index.tsx @@ -15,8 +15,9 @@ function index({ id }: Props) { const fetchItems = async () => { try { + let apiUrl = (import.meta as any).env.VITE_API_URL; const response = await fetch( - `http://localhost:8080/api/lafresca/food/${id}`, + `${apiUrl}/food/${id}`, ); if (!response.ok) { throw new Error('Failed to fetch item');