Use request host for internal API URLs
This commit is contained in:
18
utils/requesturl.utils.go
Normal file
18
utils/requesturl.utils.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func RequestBaseURL(r *http.Request) string {
|
||||
scheme := "https"
|
||||
|
||||
if proto := r.Header.Get("X-Forwarded-Proto"); proto != "" {
|
||||
scheme = strings.TrimSpace(strings.Split(proto, ",")[0])
|
||||
} else if r.TLS != nil {
|
||||
scheme = "https"
|
||||
}
|
||||
|
||||
return scheme + "://" + r.Host
|
||||
}
|
||||
Reference in New Issue
Block a user