Skip to content

Commit

Permalink
fix port in external host causing url parse fail
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyler84 authored and Eugeny committed Nov 16, 2023
1 parent d9af747 commit b982abb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion warpgate-common/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ impl WarpgateConfig {
// if trust x-forwarded, get x-forwarded-proto, then try request scheme, then fallback https
// if trust x-forwarded, get x-forwarded-port, then try request port, then fallback http listen port
let trust_forwarded_headers = self.store.http.trust_x_forwarded_headers;
let (scheme, host, port) = ("https".to_string(), self.store.external_host.clone(), self.store.http.listen.port());
let url = self.store.external_host.as_ref().map(|x| Url::parse(&format!("https://{}/", x))).and_then(|x| x.ok());
let (scheme, host, port) = url
.map_or(
("https".to_string(), self.store.external_host.clone(), self.store.http.listen.port()), |
x| (x.scheme().to_string(), x.host().map(|x| x.to_string()).or(self.store.external_host.clone()), x.port().unwrap_or(self.store.http.listen.port())));

let (scheme, host, port) = match for_request {
Some(req) => {
Expand Down

0 comments on commit b982abb

Please sign in to comment.