mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-13 20:23:47 +00:00
* fix(nginx): defer cors to gateway allowlist Remove proxy-level wildcard CORS handling so browser origins are controlled by the Gateway allowlist and stay aligned with CSRF origin checks. * docs: document gateway cors allowlist Clarify that same-origin nginx access needs no CORS headers while split-origin or port-forwarded browser clients must opt in with GATEWAY_CORS_ORIGINS. * docs(gateway): record cors source of truth Document that Gateway CORSMiddleware and CSRFMiddleware share GATEWAY_CORS_ORIGINS as the split-origin source of truth. * fix(gateway): align cors origin normalization * docs: clarify gateway langgraph routing * docs(gateway): update runtime routing note
27 lines
892 B
Python
27 lines
892 B
Python
import os
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class GatewayConfig(BaseModel):
|
|
"""Configuration for the API Gateway."""
|
|
|
|
host: str = Field(default="0.0.0.0", description="Host to bind the gateway server")
|
|
port: int = Field(default=8001, description="Port to bind the gateway server")
|
|
enable_docs: bool = Field(default=True, description="Enable Swagger/ReDoc/OpenAPI endpoints")
|
|
|
|
|
|
_gateway_config: GatewayConfig | None = None
|
|
|
|
|
|
def get_gateway_config() -> GatewayConfig:
|
|
"""Get gateway config, loading from environment if available."""
|
|
global _gateway_config
|
|
if _gateway_config is None:
|
|
_gateway_config = GatewayConfig(
|
|
host=os.getenv("GATEWAY_HOST", "0.0.0.0"),
|
|
port=int(os.getenv("GATEWAY_PORT", "8001")),
|
|
enable_docs=os.getenv("GATEWAY_ENABLE_DOCS", "true").lower() == "true",
|
|
)
|
|
return _gateway_config
|