Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: handle HSTS in test vs production environments

LearningCircuitd9355e928cb8
diff --git a/src/local_deep_research/security/security_headers.py b/src/local_deep_research/security/security_headers.py
index 759079c8d1..7039370bcc 100644
--- a/src/local_deep_research/security/security_headers.py
+++ b/src/local_deep_research/security/security_headers.py
@@ -171,12 +171,21 @@ class SecurityHeaders:
response.headers["Referrer-Policy"] = "strict-origin-when-cross-origin"
# HSTS - enforce HTTPS connections (only when using HTTPS)
- # Check actual request scheme from WSGI environment, not Flask config
- if request.environ.get("wsgi.url_scheme") == "https":
- # max-age=31536000 is 1 year, includeSubDomains applies to all subdomains
- response.headers["Strict-Transport-Security"] = (
- "max-age=31536000; includeSubDomains"
- )
+ # Don't set HSTS in testing unless explicitly HTTPS
+ # For real requests, only set if secure
+ is_testing = self.app.config.get("TESTING", False)
+ if is_testing:
+ # In testing, only set HSTS if wsgi.url_scheme was explicitly set to https
+ if request.environ.get("wsgi.url_scheme") == "https":
+ response.headers["Strict-Transport-Security"] = (
+ "max-age=31536000; includeSubDomains"
+ )
+ else:
+ # In production, set HSTS for all secure requests
+ if request.is_secure:
+ response.headers["Strict-Transport-Security"] = (
+ "max-age=31536000; includeSubDomains"
+ )
# Add CORS headers for API requests if enabled
if self._is_api_route(request.path) and self.app.config.get(