|
|
@@ -39,11 +39,29 @@ from content_agent.schemas import (
|
|
|
app = FastAPI(title="Content Agent V1")
|
|
|
service = RunService.from_env()
|
|
|
|
|
|
+def _load_project_env_value(key: str) -> str | None:
|
|
|
+ if os.environ.get(key) is not None:
|
|
|
+ return os.environ[key]
|
|
|
+ env_path = os.environ.get("CONTENT_AGENT_ENV_FILE") or ".env"
|
|
|
+ try:
|
|
|
+ lines = open(env_path, encoding="utf-8").read().splitlines()
|
|
|
+ except OSError:
|
|
|
+ return None
|
|
|
+ for line in lines:
|
|
|
+ stripped = line.strip()
|
|
|
+ if not stripped or stripped.startswith("#") or "=" not in stripped:
|
|
|
+ continue
|
|
|
+ name, value = stripped.split("=", 1)
|
|
|
+ if name.strip() == key:
|
|
|
+ return value.strip().strip('"').strip("'")
|
|
|
+ return None
|
|
|
+
|
|
|
+
|
|
|
_cors_origins = [
|
|
|
origin.strip()
|
|
|
- for origin in os.environ.get(
|
|
|
- "CONTENT_AGENT_WEB_CORS_ORIGINS",
|
|
|
- "http://localhost:3000,http://127.0.0.1:3000,http://localhost:3010,http://127.0.0.1:3010",
|
|
|
+ for origin in (
|
|
|
+ _load_project_env_value("CONTENT_AGENT_WEB_CORS_ORIGINS")
|
|
|
+ or "http://localhost:3000,http://127.0.0.1:3000,http://localhost:3010,http://127.0.0.1:3010"
|
|
|
).split(",")
|
|
|
if origin.strip()
|
|
|
]
|