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

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 . import models
from .database import engine from .database import engine
from .routers import auth, templates, instances, admin, console from .routers import auth, templates, instances, admin
# Структурированное логирование: единый формат для контейнера. # Структурированное логирование: единый формат для контейнера.
logging.basicConfig( logging.basicConfig(
@@ -19,18 +19,17 @@ models.Base.metadata.create_all(bind=engine)
app = FastAPI( app = FastAPI(
title="Proxmox VPS Panel", title="Proxmox VPS Panel",
version="0.2.0", version="0.3.0",
description="Self-hosted панель для управления VPS на Proxmox VE.", description="Self-hosted панель для управления VPS на Proxmox VE.",
) )
# CORS: список доменов через переменную окружения ALLOW_ORIGINS (через запятую). # CORS: список доменов через переменную окружения ALLOW_ORIGINS (через запятую).
# Дефолт — только локальный фронтенд. В проде обязательно задать конкретный домен.
_origins_raw = os.getenv("ALLOW_ORIGINS", "http://localhost:5173,http://127.0.0.1:5173") _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()] allow_origins = [o.strip() for o in _origins_raw.split(",") if o.strip()]
if "*" in allow_origins: if "*" in allow_origins:
logger.warning( 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(templates.router)
app.include_router(instances.router) app.include_router(instances.router)
app.include_router(admin.router) app.include_router(admin.router)
app.include_router(console.router)
@app.get("/health") @app.get("/health")
def health(): def health():
"""Healthcheck — проверяет только то, что приложение живо.""" """Healthcheck — приложение живо."""
return {"status": "ok"} return {"status": "ok"}
@app.get("/health/ready") @app.get("/health/ready")
def readiness(): def readiness():
"""Readiness — можно расширить проверкой БД и Proxmox при необходимости.""" """Readiness — готов к приёму трафика."""
return {"status": "ready"} return {"status": "ready"}