Skip to content

feat: add cors support #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
LOG_LEVEL=INFO
API_HOST=127.0.0.1
API_PORT=8000
CORS_ALLOWED_ORIGINS="*" # comma-separated list of allowed origins
AGENTS_REF='{"agent_uuid": "agent_module_name:agent_var"}'
AGENT_MANIFEST_PATH=manifest.json
AGWS_STORAGE_PERSIST=True
Expand Down
2 changes: 1 addition & 1 deletion src/agent_workflow_server/logging/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@

CustomLoggerHandler = handler

LOG_LEVEL = os.environ.get("LOG_LEVEL", "INFO").upper()
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO").upper()
logging.basicConfig(level=LOG_LEVEL, handlers=[CustomLoggerHandler], force=True)
9 changes: 9 additions & 0 deletions src/agent_workflow_server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import uvicorn
from dotenv import find_dotenv, load_dotenv
from fastapi import Depends, FastAPI
from fastapi.middleware.cors import CORSMiddleware

from agent_workflow_server.agents.load import load_agents
from agent_workflow_server.apis.agents import public_router as PublicAgentsApiRouter
Expand Down Expand Up @@ -60,6 +61,14 @@
dependencies=[Depends(authentication_with_api_key)],
)

app.add_middleware(
CORSMiddleware,
allow_origins=os.getenv("CORS_ALLOWED_ORIGINS", "*").split(","),
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)


def signal_handler(sig, frame):
logger.warning(f"Received {signal.Signals(sig).name}. Exiting...")
Expand Down