Skip to content

Commit be43e42

Browse files
committed
feat: add support for CORS origin regex configuration
1 parent 78781ef commit be43e42

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

backend/app/core/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def server_host(self) -> str:
6060
BACKEND_CORS_ORIGINS: Annotated[
6161
list[AnyUrl] | str, BeforeValidator(parse_cors)
6262
] = []
63+
BACKEND_CORS_ORIGIN_REGEXP: str | None = None
6364

6465
PROJECT_NAME: str = "TiDB.AI"
6566
SENTRY_DSN: HttpUrl | None = None

backend/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ async def lifespan(app: FastAPI):
9393
allow_origins=[
9494
str(origin).strip("/") for origin in settings.BACKEND_CORS_ORIGINS
9595
],
96+
allow_origin_regex=settings.BACKEND_CORS_ORIGIN_REGEXP,
9697
allow_credentials=True,
9798
allow_methods=["*"],
9899
allow_headers=["*"],

0 commit comments

Comments
 (0)