v0.13.9-ha_addon
This commit is contained in:
+19
-16
@@ -67,23 +67,26 @@ fn request_base_path(state: &AppState, headers: &HeaderMap) -> String {
|
||||
}
|
||||
|
||||
fn forwarded_prefix(headers: &HeaderMap) -> Option<String> {
|
||||
let raw = headers
|
||||
.get("x-forwarded-prefix")?
|
||||
.to_str()
|
||||
.ok()?
|
||||
.split(',')
|
||||
.next()?
|
||||
.trim();
|
||||
if raw.is_empty() || raw == "/" {
|
||||
return Some(String::new());
|
||||
// Home Assistant ingress uses X-Ingress-Path. Generic reverse proxies
|
||||
// commonly use X-Forwarded-Prefix, so support both with HA taking
|
||||
// precedence when both are present.
|
||||
for header in ["x-ingress-path", "x-forwarded-prefix"] {
|
||||
let Some(raw) = headers.get(header).and_then(|value| value.to_str().ok()) else {
|
||||
continue;
|
||||
};
|
||||
let raw = raw.split(',').next().unwrap_or_default().trim();
|
||||
if raw.is_empty() || raw == "/" {
|
||||
return Some(String::new());
|
||||
}
|
||||
if raw.contains('?')
|
||||
|| raw.contains('#')
|
||||
|| raw.split('/').any(|part| matches!(part, "." | ".."))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return Some(format!("/{}", raw.trim_matches('/')));
|
||||
}
|
||||
if raw.contains('?')
|
||||
|| raw.contains('#')
|
||||
|| raw.split('/').any(|part| matches!(part, "." | ".."))
|
||||
{
|
||||
return None;
|
||||
}
|
||||
Some(format!("/{}", raw.trim_matches('/')))
|
||||
None
|
||||
}
|
||||
async fn app_js() -> Response {
|
||||
static_response(
|
||||
|
||||
Reference in New Issue
Block a user