From e2209f8b3808f3622382f1db5ea002aca7720215 Mon Sep 17 00:00:00 2001 From: dr-frmr Date: Wed, 6 Nov 2024 16:43:57 -0500 Subject: [PATCH] pronto proto --- kinode/src/http/server.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kinode/src/http/server.rs b/kinode/src/http/server.rs index 408678a0..1f29b2b4 100644 --- a/kinode/src/http/server.rs +++ b/kinode/src/http/server.rs @@ -378,10 +378,19 @@ async fn login_handler( Ok(v) => { response.headers_mut().append("set-cookie", v); if let Some(redirect) = query_params.get("redirect") { + // get http/https from request headers + let proto = match response.headers().get("X-Forwarded-Proto") { + Some(proto) => proto.to_str().unwrap_or("http").to_string(), + None => "http".to_string(), + }; + response.headers_mut().append( "Location", - HeaderValue::from_str(&format!("http://{}{redirect}", host.unwrap())) - .unwrap(), + HeaderValue::from_str(&format!( + "{proto}://{}{redirect}", + host.unwrap() + )) + .unwrap(), ); response .headers_mut()