Skip to content

Commit 666691c

Browse files
Flynn-ZhCopilot
andauthored
Update mineru/cli/fast_api.py
Co-authored-by: Copilot <[email protected]>
1 parent fb60e48 commit 666691c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

mineru/cli/fast_api.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@ async def limit_concurrency():
4343
yield
4444

4545

46-
app = FastAPI(openapi_url=None, docs_url=None, redoc_url=None)
46+
# By default, the OpenAPI documentation endpoints (openapi_url, docs_url, redoc_url) are disabled for security reasons.
47+
# To enable the FastAPI docs and schema endpoints, set the environment variable ENABLE_FASTAPI_DOCS=1.
48+
enable_docs = os.getenv("ENABLE_FASTAPI_DOCS", "0") == "1"
49+
app = FastAPI(
50+
openapi_url="/openapi.json" if enable_docs else None,
51+
docs_url="/docs" if enable_docs else None,
52+
redoc_url="/redoc" if enable_docs else None,
53+
)
4754
app.add_middleware(GZipMiddleware, minimum_size=1000)
4855

4956

0 commit comments

Comments
 (0)