Skip to content

Commit 63aa8e2

Browse files
committed
Add NEXT_PUBLIC_BUILD_TIME to config and append timestamp to API requests for fresh category data retrieval
1 parent 4ca4504 commit 63aa8e2

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

frontend/next.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ const nextConfig = {
1414
],
1515
},
1616

17+
env: {
18+
NEXT_PUBLIC_BUILD_TIME: Date.now(),
19+
},
20+
1721
output: "export",
1822
basePath: "/ProxmoxVE",
1923
};

frontend/src/app/scripts/page.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ function ScriptContent() {
4747
};
4848

4949
useEffect(() => {
50-
fetch("api/categories")
51-
.then((response) => response.json())
52-
.then((categories) => {
53-
const sortedCategories = sortCategories(categories);
54-
setLinks(sortedCategories);
55-
})
56-
.catch((error) => console.error(error));
50+
fetch(
51+
`/api/categories?_=${process.env.NEXT_PUBLIC_BUILD_TIME || Date.now()}`,
52+
)
53+
.then((response) => response.json())
54+
.then((categories) => {
55+
const sortedCategories = sortCategories(categories);
56+
setLinks(sortedCategories);
57+
})
58+
.catch((error) => console.error(error));
5759
}, []);
5860

5961
return (

frontend/src/components/CommandMenu.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,19 @@ export default function CommandMenu() {
5252

5353
const fetchCategories = async () => {
5454
setIsLoading(true);
55-
fetch("api/categories")
56-
.then((response) => response.json())
57-
.then((categories) => {
58-
const sortedCategories = sortCategories(categories);
59-
setLinks(sortedCategories);
60-
setIsLoading(false);
61-
})
62-
.catch((error) => {
63-
setIsLoading(false);
64-
console.error(error)
65-
});
55+
fetch(
56+
`/api/categories?_=${process.env.NEXT_PUBLIC_BUILD_TIME || Date.now()}`,
57+
)
58+
.then((response) => response.json())
59+
.then((categories) => {
60+
const sortedCategories = sortCategories(categories);
61+
setLinks(sortedCategories);
62+
setIsLoading(false);
63+
})
64+
.catch((error) => {
65+
setIsLoading(false);
66+
console.error(error);
67+
});
6668
};
6769

6870
return (

0 commit comments

Comments
 (0)