Respect `PYX_API_URL` when suggesting `uv auth login` on 401 (#15774)

This commit is contained in:
Zanie Blue 2025-09-10 14:24:46 -05:00 committed by GitHub
parent ccf01fff66
commit 27d205b0c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 10 deletions

View File

@ -465,11 +465,18 @@ impl Middleware for AuthMiddleware {
if let Some(response) = response {
Ok(response)
} else {
if is_known_url {
} else if let Some(store) = is_known_url
.then_some(self.pyx_token_store.as_ref())
.flatten()
{
let domain = store
.api()
.domain()
.unwrap_or("pyx.dev")
.trim_start_matches("api.");
Err(Error::Middleware(format_err!(
"Run `{}` to authenticate the uv CLI",
"uv auth login pyx.dev".green()
"Run `{}` to authenticate uv with pyx",
format!("uv auth login {domain}").green()
)))
} else {
Err(Error::Middleware(format_err!(
@ -477,7 +484,6 @@ impl Middleware for AuthMiddleware {
)))
}
}
}
}
impl AuthMiddleware {