diff --git a/Dockerfile b/Dockerfile index eef9157..4965151 100644 --- a/Dockerfile +++ b/Dockerfile @@ -125,6 +125,7 @@ stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 +environment=API_ROOT_PATH="/api" EOF # Set permissions diff --git a/backend/main.py b/backend/main.py index fa0901f..f080e90 100644 --- a/backend/main.py +++ b/backend/main.py @@ -33,6 +33,12 @@ async def lifespan(app: FastAPI): print("👋 KV-Pix FastAPI Backend shutting down...") +import os + +# Detect if running behind nginx proxy (via env var) +# When behind nginx at /api, set root_path so Swagger knows correct URL prefix +ROOT_PATH = os.getenv("API_ROOT_PATH", "") + app = FastAPI( title="KV-Pix API", description=""" @@ -50,10 +56,11 @@ A powerful API for AI image generation using multiple providers. All generation endpoints require provider-specific cookies passed in the request body. See the Settings page in the web app for cookie configuration instructions. """, - version="1.0.0", + version="3.2.0", lifespan=lifespan, docs_url="/docs", - redoc_url="/redoc" + redoc_url="/redoc", + root_path=ROOT_PATH, ) # CORS middleware - allow Next.js frontend