From 422c402bab7f05e46274ede11f234a19a62e093e Mon Sep 17 00:00:00 2001 From: Michele Dolfi <97102151+dolfim-ibm@users.noreply.github.com> Date: Mon, 17 Mar 2025 09:49:17 +0100 Subject: [PATCH] fix: allow changes in CORS settings (#100) Signed-off-by: Michele Dolfi --- docling_serve/app.py | 6 +++--- docling_serve/settings.py | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docling_serve/app.py b/docling_serve/app.py index 35c967f..5ef0abf 100644 --- a/docling_serve/app.py +++ b/docling_serve/app.py @@ -122,9 +122,9 @@ def create_app(): # noqa: C901 version=version, ) - origins = ["*"] - methods = ["*"] - headers = ["*"] + origins = docling_serve_settings.cors_origins + methods = docling_serve_settings.cors_methods + headers = docling_serve_settings.cors_headers app.add_middleware( CORSMiddleware, diff --git a/docling_serve/settings.py b/docling_serve/settings.py index f493e3e..0c9c3e5 100644 --- a/docling_serve/settings.py +++ b/docling_serve/settings.py @@ -32,6 +32,10 @@ class DoclingServeSettings(BaseSettings): artifacts_path: Optional[Path] = None options_cache_size: int = 2 + cors_origins: list[str] = ["*"] + cors_methods: list[str] = ["*"] + cors_headers: list[str] = ["*"] + eng_kind: AsyncEngine = AsyncEngine.LOCAL eng_loc_num_workers: int = 2