Compare commits

..

1 Commits

Author SHA1 Message Date
Stavros
2c7a3fc801 refactor: simplify cookie secure logic 2025-01-25 16:29:18 +02:00

View File

@@ -55,20 +55,12 @@ func (api *API) Init() {
domain, domainErr := utils.GetRootURL(api.Config.AppURL) domain, domainErr := utils.GetRootURL(api.Config.AppURL)
log.Info().Str("domain", domain).Msg("Using domain for cookies")
if domainErr != nil { if domainErr != nil {
log.Fatal().Err(domainErr).Msg("Failed to get domain") log.Fatal().Err(domainErr).Msg("Failed to get domain")
os.Exit(1) os.Exit(1)
} }
var isSecure bool log.Info().Str("domain", domain).Msg("Using domain for cookies")
if api.Config.CookieSecure {
isSecure = true
} else {
isSecure = false
}
api.Domain = fmt.Sprintf(".%s", domain) api.Domain = fmt.Sprintf(".%s", domain)
@@ -76,7 +68,7 @@ func (api *API) Init() {
Domain: api.Domain, Domain: api.Domain,
Path: "/", Path: "/",
HttpOnly: true, HttpOnly: true,
Secure: isSecure, Secure: api.Config.CookieSecure,
MaxAge: api.Config.CookieExpiry, MaxAge: api.Config.CookieExpiry,
}) })