dynamic base url

This commit is contained in:
Simon
2026-03-10 18:45:32 +00:00
parent 2ad131f38f
commit 96926563b8
10 changed files with 118 additions and 43 deletions

View File

@@ -119,6 +119,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
.and_then(|h| h.to_str().ok())
.unwrap_or_default()
.to_string();
let public_url_base = format!("{}://{}", req.connection_info().scheme(), host);
let mut status = Status::new();
for (provider_name, provider) in ALL_PROVIDERS.iter() {
@@ -126,7 +127,12 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
provider.get_channel(clientversion.clone())
}));
match channel_result {
Ok(Some(channel)) => status.add_channel(channel),
Ok(Some(mut channel)) => {
if channel.favicon.starts_with('/') {
channel.favicon = format!("{}{}", public_url_base, channel.favicon);
}
status.add_channel(channel)
}
Ok(None) => {}
Err(payload) => {
let panic_msg = panic_payload_to_string(payload);
@@ -134,7 +140,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
}
}
}
status.iconUrl = format!("http://{}/favicon.ico", host).to_string();
status.iconUrl = format!("{}/favicon.ico", public_url_base).to_string();
Ok(web::HttpResponse::Ok().json(&status))
}
@@ -245,12 +251,18 @@ async fn videos_post(
.to_string();
let duration = video_request.duration.as_deref().unwrap_or("").to_string();
let sexuality = video_request.sexuality.as_deref().unwrap_or("").to_string();
let public_url_base = format!(
"{}://{}",
req.connection_info().scheme(),
req.connection_info().host()
);
let options = ServerOptions {
featured: Some(featured),
category: Some(category),
sites: Some(sites),
filter: Some(filter),
language: Some(language),
public_url_base: Some(public_url_base),
requester: Some(requester),
network: Some(network),
stars: Some(stars),