diff --git a/packages/app-lib/src/util/fetch.rs b/packages/app-lib/src/util/fetch.rs index 74b947b4e..5add7f029 100644 --- a/packages/app-lib/src/util/fetch.rs +++ b/packages/app-lib/src/util/fetch.rs @@ -90,7 +90,7 @@ where #[allow(clippy::too_many_arguments)] pub async fn fetch_advanced( method: Method, - url: &str, + mut url: &str, sha1: Option<&str>, json_body: Option, header: Option<(&str, &str)>, @@ -100,6 +100,7 @@ pub async fn fetch_advanced( ) -> crate::Result { let io_semaphore = semaphore.0.read().await; let _permit = io_semaphore.acquire().await?; + const FALLBACK_METADATA_URL: &str = "https://meta.modrinth.com"; for attempt in 1..=(FETCH_ATTEMPTS + 1) { let mut req = REQWEST_CLIENT.request(method.clone(), url); @@ -175,7 +176,10 @@ pub async fn fetch_advanced( return Err(err.into()); } } - Err(_) if attempt <= 3 => continue, + Err(_) if attempt <= 3 => { + url = FALLBACK_METADATA_URL; + continue; + } Err(err) => { return Err(err.into()); }