fix: mount /static/downloads before /static to avoid prefix conflict

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Андрей Бобырев
2026-05-20 13:27:54 +03:00
parent 399e9ab2fb
commit bab8fc33cc

View File

@@ -60,14 +60,15 @@ app = FastAPI(title="VPS Monitoring", lifespan=lifespan)
# Static files # Static files
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) BASE_DIR = os.path.dirname(os.path.abspath(__file__))
app.mount("/static", StaticFiles(directory=os.path.join(BASE_DIR, "static")), name="static")
templates = Jinja2Templates(directory=os.path.join(BASE_DIR, "templates")) templates = Jinja2Templates(directory=os.path.join(BASE_DIR, "templates"))
# Static downloads (Windows agent) # Static downloads (Windows agent) — mount BEFORE /static to avoid prefix conflict
DOWNLOADS_DIR = os.path.join(os.path.dirname(BASE_DIR), "windows") DOWNLOADS_DIR = os.path.join(os.path.dirname(BASE_DIR), "windows")
if os.path.isdir(DOWNLOADS_DIR): if os.path.isdir(DOWNLOADS_DIR):
app.mount("/static/downloads", StaticFiles(directory=DOWNLOADS_DIR), name="downloads") app.mount("/static/downloads", StaticFiles(directory=DOWNLOADS_DIR), name="downloads")
app.mount("/static", StaticFiles(directory=os.path.join(BASE_DIR, "static")), name="static")
# Include routers # Include routers
app.include_router(servers_router) app.include_router(servers_router)
app.include_router(auth_router) app.include_router(auth_router)