Обновление файла

This commit is contained in:
2026-07-25 03:27:16 +03:00
parent 2575119330
commit 7628698775
+6 -8
View File
@@ -6,7 +6,7 @@ from fastapi.middleware.cors import CORSMiddleware
from . import models
from .database import engine
from .routers import auth, templates, instances, admin, console
from .routers import auth, templates, instances, admin
# Структурированное логирование: единый формат для контейнера.
logging.basicConfig(
@@ -19,18 +19,17 @@ models.Base.metadata.create_all(bind=engine)
app = FastAPI(
title="Proxmox VPS Panel",
version="0.2.0",
version="0.3.0",
description="Self-hosted панель для управления VPS на Proxmox VE.",
)
# CORS: список доменов через переменную окружения ALLOW_ORIGINS (через запятую).
# Дефолт — только локальный фронтенд. В проде обязательно задать конкретный домен.
_origins_raw = os.getenv("ALLOW_ORIGINS", "http://localhost:5173,http://127.0.0.1:5173")
allow_origins = [o.strip() for o in _origins_raw.split(",") if o.strip()]
if "*" in allow_origins:
logger.warning(
"ALLOW_ORIGINS='*' это небезопасно для прода и не работает с allow_credentials=True. "
"ALLOW_ORIGINS='*' — небезопасно для прода и не работает с allow_credentials=True. "
"Укажите конкретные домены."
)
@@ -46,16 +45,15 @@ app.include_router(auth.router)
app.include_router(templates.router)
app.include_router(instances.router)
app.include_router(admin.router)
app.include_router(console.router)
@app.get("/health")
def health():
"""Healthcheck — проверяет только то, что приложение живо."""
"""Healthcheck — приложение живо."""
return {"status": "ok"}
@app.get("/health/ready")
def readiness():
"""Readiness — можно расширить проверкой БД и Proxmox при необходимости."""
return {"status": "ready"}
"""Readiness — готов к приёму трафика."""
return {"status": "ready"}