diff --git a/next.config.mjs b/next.config.mjs index 6078b15..e9ed127 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -14,6 +14,10 @@ const nextConfig = { ], }, + env: { + NEXT_PUBLIC_BUILD_TIME: `${Date.now()}`, + }, + output: "export", // basePath: "/proxmox-helper-scripts", }; diff --git a/src/app/scripts/page.tsx b/src/app/scripts/page.tsx index 58f37be..4a56b62 100644 --- a/src/app/scripts/page.tsx +++ b/src/app/scripts/page.tsx @@ -47,7 +47,9 @@ function ScriptContent() { }; useEffect(() => { - fetch("api/categories") + fetch( + `api/categories?_=${process.env.NEXT_PUBLIC_BUILD_TIME || Date.now()}`, + ) .then((response) => response.json()) .then((categories) => { const sortedCategories = sortCategories(categories); diff --git a/src/components/CommandMenu.tsx b/src/components/CommandMenu.tsx index fedc51b..2e0ed3b 100644 --- a/src/components/CommandMenu.tsx +++ b/src/components/CommandMenu.tsx @@ -50,24 +50,13 @@ export default function CommandMenu() { }, []); React.useEffect(() => { - const fetchCategories = async (): Promise => { - try { - const response = await fetch("api/categories"); - if (!response.ok) { - throw new Error("Failed to fetch categories"); - } - const categories: Category[] = await response.json(); - if (categories.length === 0) { - throw new Error("Empty response"); - } + fetch(`api/categories?_=${process.env.NEXT_PUBLIC_BUILD_TIME || Date.now()}`) + .then((response) => response.json()) + .then((categories) => { const sortedCategories = sortCategories(categories); setLinks(sortedCategories); - } catch (error) { - console.error(error); - } - }; - - fetchCategories(); + }) + .catch((error) => console.error(error)); }, []); return (