get host from header in proxy call

This commit is contained in:
Alireza Ahmadi
2024-11-02 13:14:07 +01:00
parent ebf45c2131
commit 088eb6dd94
2 changed files with 14 additions and 3 deletions

View File

@@ -61,7 +61,11 @@ func html(c *gin.Context, name string, title string, data gin.H) {
data = gin.H{}
}
data["title"] = title
data["host"], _, _ = net.SplitHostPort(c.Request.Host)
host := c.Request.Host
if colonIndex := strings.LastIndex(host, ":"); colonIndex != -1 {
host, _, _ = net.SplitHostPort(c.Request.Host)
}
data["host"] = host
data["request_uri"] = c.Request.RequestURI
data["base_path"] = c.GetString("base_path")
c.HTML(http.StatusOK, name, getContext(data))