Skip to content

Commit 727cfe0

Browse files
committed
chore(cert): disable FastAPI docs in prod by default
1 parent 214896a commit 727cfe0

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

β€Žcert/backend/src/main.pyβ€Ž

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ def configure_logging() -> None:
2222
configure_logging()
2323
logger = logging.getLogger(__name__)
2424

25+
environment = os.getenv("ENVIRONMENT", "dev").lower()
26+
hide_docs = environment.startswith("prod")
27+
2528
# FastAPI μ•± 생성
2629
app = FastAPI(
2730
title="PseudoLab 수료증 λ°œκΈ‰ μ‹œμŠ€ν…œ",
2831
description="PseudoLab 수료증 λ°œκΈ‰μ„ μœ„ν•œ API μ„œλ²„",
2932
version="1.0.0",
30-
docs_url="/docs",
31-
redoc_url="/redoc",
33+
docs_url=None if hide_docs else "/docs",
34+
redoc_url=None if hide_docs else "/redoc",
35+
openapi_url=None if hide_docs else "/openapi.json",
3236
)
3337

3438
# CORS 미듀웨어 μ„€μ •

β€Žcert/docker-compose.yamlβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ services:
5858
- traefik.docker.network=traefik
5959

6060
# --- Traefik Router (backend) ---
61-
- traefik.http.routers.cert-${ENVIRONMENT}-api.rule=Host(`${APP_HOST}`) && (PathPrefix(`/api`) || PathPrefix(`/docs`) || PathPrefix(`/redoc`) || PathPrefix(`/health`) || Path(`/openapi.json`))
61+
# Docs/Redoc/OpenAPI κ²½λ‘œλŠ” λΌμš°νŒ…ν•˜λ˜, λ°±μ—”λ“œμ—μ„œ prod ν™˜κ²½μ—μ„œλŠ” λΉ„ν™œμ„±ν™”λœλ‹€.
62+
- traefik.http.routers.cert-${ENVIRONMENT}-api.rule=Host(`${APP_HOST}`) && (PathPrefix(`/api`) || PathPrefix(`/health`) || PathPrefix(`/docs`) || PathPrefix(`/redoc`) || Path(`/openapi.json`))
6263
- traefik.http.routers.cert-${ENVIRONMENT}-api.entrypoints=websecure
6364
- traefik.http.routers.cert-${ENVIRONMENT}-api.tls=true
6465
- traefik.http.routers.cert-${ENVIRONMENT}-api.tls.certresolver=le

0 commit comments

Comments
Β (0)