Make HSTS policy configurable if https is enabled

This commit is contained in:
Konstantin Kayukin 2026-05-18 18:01:34 +02:00
parent f9ae0347c6
commit 1120627cd5
2 changed files with 8 additions and 0 deletions

View file

@ -57,6 +57,11 @@ func IsDebug() bool {
return os.Getenv("XUI_DEBUG") == "true"
}
// IsSkipHSTS returns true if skipping HSTS mode is enabled via the XUI_SKIP_HSTS environment variable.
func IsSkipHSTS() bool {
return os.Getenv("XUI_SKIP_HSTS") == "true"
}
// GetBinFolderPath returns the path to the binary folder, defaulting to "bin" if not set via XUI_BIN_FOLDER.
func GetBinFolderPath() string {
binFolderPath := os.Getenv("XUI_BIN_FOLDER")

View file

@ -132,6 +132,9 @@ func NewServer() *Server {
}
func (s *Server) isDirectHTTPSConfigured() bool {
if config.IsSkipHSTS() {
return false
}
certFile, certErr := s.settingService.GetCertFile()
keyFile, keyErr := s.settingService.GetKeyFile()
if certErr != nil || keyErr != nil || certFile == "" || keyFile == "" {