Skip to content

Commit 3fc334b

Browse files
Mini256NG85
authored andcommitted
feat: add support for CORS origin regex configuration (pingcap#695)
1 parent c568267 commit 3fc334b

File tree

4 files changed

+1847
-2515
lines changed

4 files changed

+1847
-2515
lines changed

backend/app/core/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def server_host(self) -> str:
6565
BACKEND_CORS_ORIGINS: Annotated[
6666
list[AnyUrl] | str, BeforeValidator(parse_cors)
6767
] = []
68+
BACKEND_CORS_ORIGIN_REGEXP: str | None = None
6869

6970
PROJECT_NAME: str = "APTSELL.AI"
7071
SENTRY_DSN: HttpUrl | None = None

backend/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ async def lifespan(app: FastAPI):
9696
allow_origins=[
9797
str(origin).strip("/") for origin in settings.BACKEND_CORS_ORIGINS
9898
],
99+
allow_origin_regex=settings.BACKEND_CORS_ORIGIN_REGEXP,
99100
allow_credentials=True,
100101
allow_methods=["*"],
101102
allow_headers=["*"],

backend/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ authors = [
88
{ name = "admin", email = "[email protected]"}
99
]
1010
readme = "README.md"
11-
requires-python = ">= 3.9"
11+
requires-python = ">= 3.10"
1212
dependencies = [
1313
"fastapi>=0.115.6",
1414
"fastapi-cli>=0.0.5",

0 commit comments

Comments
 (0)