Skip to content

Commit 7a14d35

Browse files
Merge pull request #1 from offendingcommit/claude/add-cors-env-support-xe245
Make CORS origins configurable via environment variable
2 parents a3e8000 + 12d62a3 commit 7a14d35

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/main.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import os
23
import re
34
import uuid
45
from collections.abc import Awaitable, Callable
@@ -168,9 +169,12 @@ async def lifespan(_: FastAPI):
168169
)
169170

170171
origins = [
171-
"http://localhost",
172-
"http://127.0.0.1:8000",
173-
"https://api.honcho.dev",
172+
origin.strip()
173+
for origin in os.getenv(
174+
"CORS_ORIGINS",
175+
"http://localhost,http://127.0.0.1:8000,https://api.honcho.dev",
176+
).split(",")
177+
if origin.strip()
174178
]
175179

176180
app.add_middleware(

0 commit comments

Comments
 (0)