Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

set secure cookie if BASE_URL scheme is HTTPS (#4623)

ruslandogacb365c2fa003
diff --git a/config/runtime.exs b/config/runtime.exs
index e07528fcd9..22fdeb37e4 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -296,9 +296,15 @@ if byte_size(websocket_url) > 0 and
"""
end
+secure_cookie_default =
+ case base_url.scheme do
+ "http" -> "false"
+ "https" -> "true"
+ end
+
secure_cookie =
config_dir
- |> get_var_from_path_or_env("SECURE_COOKIE", if(is_selfhost, do: "false", else: "true"))
+ |> get_var_from_path_or_env("SECURE_COOKIE", secure_cookie_default)
|> String.to_existing_atom()
license_key = get_var_from_path_or_env(config_dir, "LICENSE_KEY", "")