From 265a84a51e4d83b8bded3bbf49dcf08494e2efe2 Mon Sep 17 00:00:00 2001 From: mesutoezdil Date: Wed, 29 Jul 2026 14:43:55 +0200 Subject: [PATCH] fix: remove the Docker Hub pull count fetch Docker Hub's API returns no Access-Control-Allow-Origin header, so the browser blocks this request every time. The catch block hid the failure and the displayed number always stayed at the hardcoded fallback, but the blocked request still logged a CORS error on every homepage load. Dropping the fetch keeps the same number on screen and clears the console error. The GitHub stars fetch is untouched, api.github.com does send the header. Signed-off-by: mesutoezdil --- src/pages/index.js | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/pages/index.js b/src/pages/index.js index 45c57aaad..ce7866f4f 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -375,7 +375,8 @@ export default function Home() { const { i18n } = useDocusaurusContext(); const isZh = i18n.currentLocale === "zh"; const [starsCount, setStarsCount] = useState(3100); - const [dockerPulls, setDockerPulls] = useState(325000); + // Static: Docker Hub's API sends no CORS header, so it cannot be read from the browser. + const dockerPulls = 325000; const kubernetesLogo = useBaseUrl("img/kubernetes-logo.svg"); const hamiLogo = useBaseUrl("img/hami-graph-color.svg"); const hamiHorizontalLogoLight = useBaseUrl("img/hami-horizontal-color-black.svg"); @@ -431,23 +432,7 @@ export default function Home() { } }; - const fetchDockerPulls = async () => { - try { - const response = await fetch("https://hub.docker.com/v2/repositories/projecthami/hami/", { - signal: controller.signal, - }); - if (!response.ok) return; - const data = await response.json(); - if (typeof data?.pull_count === "number") { - setDockerPulls(data.pull_count); - } - } catch (error) { - // Keep fallback value when API is unavailable. - } - }; - fetchGitHubStars(); - fetchDockerPulls(); return () => controller.abort(); }, []);