pronto proto

This commit is contained in:
dr-frmr 2024-11-06 16:43:57 -05:00
parent 84738b7b5b
commit e2209f8b38
No known key found for this signature in database

View File

@ -378,9 +378,18 @@ async fn login_handler(
Ok(v) => { Ok(v) => {
response.headers_mut().append("set-cookie", v); response.headers_mut().append("set-cookie", v);
if let Some(redirect) = query_params.get("redirect") { 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( response.headers_mut().append(
"Location", "Location",
HeaderValue::from_str(&format!("http://{}{redirect}", host.unwrap())) HeaderValue::from_str(&format!(
"{proto}://{}{redirect}",
host.unwrap()
))
.unwrap(), .unwrap(),
); );
response response