From 2c7a3fc8016d85aa47f11691ceec907e3ec1cf45 Mon Sep 17 00:00:00 2001 From: Stavros Date: Sat, 25 Jan 2025 16:29:18 +0200 Subject: [PATCH] refactor: simplify cookie secure logic --- internal/api/api.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/internal/api/api.go b/internal/api/api.go index af99499..1dfa6af 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -55,20 +55,12 @@ func (api *API) Init() { domain, domainErr := utils.GetRootURL(api.Config.AppURL) - log.Info().Str("domain", domain).Msg("Using domain for cookies") - if domainErr != nil { log.Fatal().Err(domainErr).Msg("Failed to get domain") os.Exit(1) } - var isSecure bool - - if api.Config.CookieSecure { - isSecure = true - } else { - isSecure = false - } + log.Info().Str("domain", domain).Msg("Using domain for cookies") api.Domain = fmt.Sprintf(".%s", domain) @@ -76,7 +68,7 @@ func (api *API) Init() { Domain: api.Domain, Path: "/", HttpOnly: true, - Secure: isSecure, + Secure: api.Config.CookieSecure, MaxAge: api.Config.CookieExpiry, })