Skip to content

Commit 8f5a5e6

Browse files
committed
add cors support
1 parent f91c21c commit 8f5a5e6

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

maestro_worker_python/serve.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from fastapi.responses import JSONResponse
1414
from starlette.concurrency import run_in_threadpool
1515
from importlib.machinery import SourceFileLoader
16+
from fastapi.middleware.cors import CORSMiddleware
1617

1718
from .config import settings
1819
from .response import ValidationError, WorkerResponse
@@ -25,6 +26,17 @@
2526

2627
app = FastAPI()
2728

29+
origins = ["*"]
30+
31+
app.add_middleware(
32+
CORSMiddleware,
33+
allow_origins=origins,
34+
allow_credentials=True,
35+
allow_methods=["*"],
36+
allow_headers=["*"],
37+
)
38+
39+
2840
logging.basicConfig(level=settings.log_level.upper())
2941

3042
if settings.enable_json_logging:

0 commit comments

Comments
 (0)