fix uri host

This commit is contained in:
Asim Aslam
2021-05-18 17:54:20 +01:00
parent 05ad70c1dc
commit 7c5ec79fdf

View File

@@ -16,6 +16,9 @@ var (
// API Url
APIHost = "https://api.m3o.com"
// host to proxy for
Host = "m3o.one"
)
func Handler(w http.ResponseWriter, r *http.Request) {
@@ -40,6 +43,22 @@ func Handler(w http.ResponseWriter, r *http.Request) {
Path: r.URL.Path,
}
// if the host is blank we have to set it
if len(uri.Host) == 0 {
if len(r.Host) > 0 {
log.Printf("[url/proxy] Host is set from r.Host %v", r.Host)
uri.Host = r.Host
} else {
log.Printf("[url/proxy] Host is nil, defaulting to: %v", Host)
uri.Host = Host
uri.Scheme = "https"
}
}
if len(uri.Scheme) == 0 {
uri.Scheme = "https"
}
apiURL := APIHost + "/url/proxy"
// use /v1/