Skip to content

Commit f8e9da8

Browse files
authored
feat: add support for CORS origin regex configuration (#695)
1 parent 78781ef commit f8e9da8

File tree

4 files changed

+50
-731
lines changed

4 files changed

+50
-731
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=["*"],

backend/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ authors = [
77
{ name = "mini256", email = "minianter@gmail.com" }
88
]
99
readme = "README.md"
10-
requires-python = ">= 3.9"
10+
requires-python = ">= 3.10"
1111
dependencies = [
1212
"fastapi>=0.115.6",
1313
"fastapi-cli>=0.0.5",

0 commit comments

Comments
 (0)