mirror of
https://github.com/community-scripts/Proxmox.git
synced 2026-03-31 06:34:15 -04:00
Chore: add build time to env and update API fetch to prevent caching with timestamp query parameter
This commit is contained in:
@@ -14,6 +14,10 @@ const nextConfig = {
|
||||
],
|
||||
},
|
||||
|
||||
env: {
|
||||
NEXT_PUBLIC_BUILD_TIME: `${Date.now()}`,
|
||||
},
|
||||
|
||||
output: "export",
|
||||
// basePath: "/proxmox-helper-scripts",
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -50,24 +50,13 @@ export default function CommandMenu() {
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
const fetchCategories = async (): Promise<void> => {
|
||||
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 (
|
||||
|
||||
Reference in New Issue
Block a user