Only add token when it is defined. (#3073)

* Only add token when it is defined.

* Update router/src/server.rs
This commit is contained in:
Nicolas Patry 2025-03-05 11:59:52 +01:00 committed by GitHub
parent cb42b3ad83
commit ec35976f82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1711,9 +1711,10 @@ pub async fn run(
// Shared API builder initialization // Shared API builder initialization
let api_builder = || { let api_builder = || {
let mut builder = ApiBuilder::new() let mut builder = ApiBuilder::new().with_progress(false);
.with_progress(false) if let Some(token) = authorization_token {
.with_token(authorization_token); builder = builder.with_token(Some(token));
}
if let Ok(cache_dir) = std::env::var("HUGGINGFACE_HUB_CACHE") { if let Ok(cache_dir) = std::env::var("HUGGINGFACE_HUB_CACHE") {
builder = builder.with_cache_dir(cache_dir.into()); builder = builder.with_cache_dir(cache_dir.into());