Use request host for internal API URLs

This commit is contained in:
2026-06-19 17:04:46 +07:00
parent f8ad467b3d
commit 0b1cd60738
7 changed files with 125 additions and 94 deletions

18
utils/requesturl.utils.go Normal file
View 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
}