Skip to content
Prev Previous commit
Next Next commit
less verbose please
  • Loading branch information
hanouticelina committed Aug 25, 2026
commit 5fdf1198a085ed12928c9736587c12b5ba31be40
9 changes: 3 additions & 6 deletions src/huggingface_hub/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,9 @@ def _as_int(value: str | None) -> int | None:
ENDPOINT = _HF_DEFAULT_STAGING_ENDPOINT
HUGGINGFACE_CO_URL_TEMPLATE = _HF_DEFAULT_STAGING_ENDPOINT + "/{repo_id}/resolve/{revision}/{filename}"

# Hosts we consider to be Hugging Face Hub endpoints. Includes the public Hub host and its ``hf.co`` short
# domain, the staging host, and the host of the currently configured ``ENDPOINT`` so that self-hosted / staging
# endpoints work too.
# Used to parse web URLs into ``hf://`` URIs (see ``huggingface_hub/utils/_hf_uris.py``) and to decide which
# redirects to follow while resolving files (see ``huggingface_hub/utils/_http.py``). The latter forwards the
# authorization header to these hosts, so only add a host that is trusted with the user's token.
# Hosts considered to be Hugging Face Hub endpoints: the public Hub host, its ``hf.co`` short domain, the staging
# host, and the host of the configured ``ENDPOINT``. Used to parse web URLs into ``hf://`` URIs and to decide which
# redirects to follow when resolving files. The auth header is forwarded to these hosts: only add trusted ones.
HF_URL_HOSTS: frozenset[str] = frozenset(
{"hf.co"}
| {
Expand Down
7 changes: 2 additions & 5 deletions src/huggingface_hub/utils/_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,11 +701,8 @@ def _httpx_follow_hub_redirects_with_backoff(

Used to fetch HEAD /resolve on repo or bucket files.

A redirect is followed when it targets the host of the current request (e.g. a renamed repository, or the
`/api/resolve-cache/` route) or another known Hub host (e.g. an `HF_ENDPOINT` mirror redirecting to
`huggingface.co`). Redirects to any other host are *not* followed: those point to a CDN or storage bucket, the
file metadata is already carried by the redirect response itself, and the authorization header must not be
forwarded off the Hub.
Redirects to the same host or another Hub host are followed. Redirects to any other host (CDN, storage
bucket) are not: the file metadata is on the redirect response itself and the auth header must not leave the Hub.

A backoff mechanism retries the HTTP call on errors (429, 5xx, timeout, network errors).

Expand Down
Loading