diff --git a/url/proxy/proxy.go b/url/proxy/proxy.go index 959b5b4..43b2815 100644 --- a/url/proxy/proxy.go +++ b/url/proxy/proxy.go @@ -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/