From 9d46bd8f785865260cd44204372378675c6bf3aa Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:58:02 +0100 Subject: [PATCH] Update page.tsx --- frontend/src/app/category-view/page.tsx | 27 +++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/frontend/src/app/category-view/page.tsx b/frontend/src/app/category-view/page.tsx index 9f6e25c7..3f5736d3 100644 --- a/frontend/src/app/category-view/page.tsx +++ b/frontend/src/app/category-view/page.tsx @@ -10,19 +10,20 @@ const CategoryView = () => { const [selectedCategory, setSelectedCategory] = useState(null); useEffect(() => { - const fetchCategories = async () => { - try { - const response = await fetch("/api/categories"); - if (!response.ok) { - throw new Error("Failed to fetch categories"); - } - const data = await response.json(); - console.log("Fetched categories:", data); // Debugging - setCategories(data); - } catch (error) { - console.error("Error fetching categories:", error); - } - }; + const fetchCategories = async () => { + try { + const basePath = process.env.NODE_ENV === "production" ? "/ProxmoxVE" : ""; // Passe den Basis-Pfad an + const response = await fetch(`${basePath}/api/categories`); + if (!response.ok) { + throw new Error("Failed to fetch categories"); + } + const data = await response.json(); + console.log("Fetched categories:", data); // Debugging + setCategories(data); + } catch (error) { + console.error("Error fetching categories:", error); + } + }; fetchCategories(); }, []);