diff --git a/backend/middleware/domainValidator.go b/backend/middleware/domainValidator.go index e99d35f7..4ef71eb4 100644 --- a/backend/middleware/domainValidator.go +++ b/backend/middleware/domainValidator.go @@ -1,6 +1,7 @@ package middleware import ( + "net" "net/http" "strings" @@ -9,7 +10,10 @@ import ( func DomainValidator(domain string) gin.HandlerFunc { return func(c *gin.Context) { - host := strings.Split(c.Request.Host, ":")[0] + host := c.Request.Host + if colonIndex := strings.LastIndex(host, ":"); colonIndex != -1 { + host, _, _ = net.SplitHostPort(c.Request.Host) + } if host != domain { c.AbortWithStatus(http.StatusForbidden)