fix: /api/docs возвращал 404 вместо Swagger UI

FastAPI регистрировал встроенные роуты документации на дефолтных путях
(/docs, /openapi.json), в то время как все остальные роуты подключены с
префиксом /api и только его проксирует nginx. Теперь docs_url/redoc_url/
openapi_url явно указаны под /api, поэтому Swagger UI доступен там же,
где его и ищут (как заявлено в README).
This commit is contained in:
ZProger
2026-09-02 02:01:15 +03:00
parent da1c7b5d63
commit 1e9506470f

View File

@@ -38,7 +38,18 @@ async def lifespan(app: FastAPI):
yield
app = FastAPI(title="Aurum API", version=APP_VERSION, lifespan=lifespan)
app = FastAPI(
title="Aurum API",
version=APP_VERSION,
lifespan=lifespan,
# Docs live under /api/* because nginx only proxies that prefix to the
# backend (see frontend/nginx.conf) — everything else falls through to
# the SPA's index.html, which is why the defaults (/docs, /openapi.json)
# would silently 404 through the reverse proxy.
docs_url="/api/docs",
redoc_url="/api/redoc",
openapi_url="/api/openapi.json",
)
# CORS stays off unless someone deliberately opens it, and credentials are
# only granted to a pinned list. Starlette answers a credentialed "*" by