fix: setting the cookie for proxy setup

This commit is contained in:
Lakhan Samani
2022-03-30 11:50:22 +05:30
parent fe73c2f6f8
commit 4fa9f79c3f
6 changed files with 36 additions and 17 deletions

View File

@@ -10,7 +10,20 @@ import (
)
// GetHost returns hostname from request context
// if X-Authorizer-URL header is set it is given highest priority
// if EnvKeyAuthorizerURL is set it is given second highest priority.
// if above 2 are not set the requesting host name is used
func GetHost(c *gin.Context) string {
authorizerURL := c.Request.Header.Get("X-Authorizer-URL")
if authorizerURL != "" {
return authorizerURL
}
authorizerURL = envstore.EnvStoreObj.GetStringStoreEnvVariable(constants.EnvKeyAuthorizerURL)
if authorizerURL != "" {
return authorizerURL
}
scheme := c.Request.Header.Get("X-Forwarded-Proto")
if scheme != "https" {
scheme = "http"