Sdm0 commited on
Commit
4df20bd
·
verified ·
1 Parent(s): 045418f

Deploy 973aedca

Browse files
Files changed (1) hide show
  1. backend/api.py +22 -0
backend/api.py CHANGED
@@ -35,6 +35,28 @@ from backend.integrations.endpoints import register_endpoint, unregister_endpoin
35
 
36
  app = FastAPI(title="OpenCodeReview API", version="0.1.0")
37
  logger = logging.getLogger(__name__)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  allowed_origins = [item.strip() for item in os.getenv("OCR_ALLOWED_ORIGINS", "http://localhost:5173").split(",") if item.strip()]
39
  app.add_middleware(CORSMiddleware, allow_origins=allowed_origins, allow_methods=["GET", "POST"], allow_headers=["*"], allow_credentials=True)
40
 
 
35
 
36
  app = FastAPI(title="OpenCodeReview API", version="0.1.0")
37
  logger = logging.getLogger(__name__)
38
+
39
+ def _temporary_tls_diagnostic():
40
+ """Compare verified HTTPS clients without credentials or URL disclosure."""
41
+ import httpx
42
+ proxy_set = any(os.environ.get(name) for name in ("HTTPS_PROXY", "HTTP_PROXY", "ALL_PROXY", "https_proxy", "http_proxy", "all_proxy"))
43
+ logger.warning("TLS diagnostic: proxy environment present=%s", proxy_set)
44
+ for name, client in (("httpx_default", lambda: httpx.get("https://api.cloudflare.com/client/v4/ips", timeout=10)),
45
+ ("httpx_direct", lambda: httpx.get("https://api.cloudflare.com/client/v4/ips", timeout=10, trust_env=False)),
46
+ ("requests_default", lambda: requests.get("https://api.cloudflare.com/client/v4/ips", timeout=10))):
47
+ try:
48
+ response = client()
49
+ logger.warning("TLS diagnostic: %s HTTP %s", name, response.status_code)
50
+ except Exception as exc:
51
+ types = []
52
+ seen = set()
53
+ while exc is not None and id(exc) not in seen and len(types) < 6:
54
+ seen.add(id(exc))
55
+ types.append(type(exc).__name__)
56
+ exc = exc.__cause__ or exc.__context__
57
+ logger.warning("TLS diagnostic: %s error types %s", name, " -> ".join(types))
58
+
59
+ threading.Thread(target=_temporary_tls_diagnostic, daemon=True).start()
60
  allowed_origins = [item.strip() for item in os.getenv("OCR_ALLOWED_ORIGINS", "http://localhost:5173").split(",") if item.strip()]
61
  app.add_middleware(CORSMiddleware, allow_origins=allowed_origins, allow_methods=["GET", "POST"], allow_headers=["*"], allow_credentials=True)
62