Frontend fix

This commit is contained in:
2026-07-06 15:58:53 +02:00
parent cd57ba7325
commit dd9a92d34e
3 changed files with 13 additions and 7 deletions
+10 -7
View File
@@ -43,24 +43,27 @@ async def health_check():
return {"status": "healthy", "service": "coffee-control-center-api"}
# Serve Frontend static files in production if built
FRONTEND_DIR = os.path.join(
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
"frontend", "dist", "coffee-control-center", "browser"
)
# __file__ is /app/app/main.py → go up 2 levels to reach /app
_APP_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
FRONTEND_DIR = os.path.join(_APP_ROOT, "frontend", "dist", "coffee-control-center", "browser")
# Docker fallback: files are placed at /app/frontend/dist/... by the Dockerfile
if not os.path.exists(FRONTEND_DIR):
FRONTEND_DIR = "/app/frontend/dist/coffee-control-center/browser"
if os.path.exists(FRONTEND_DIR):
@app.get("/{fallback_path:path}")
async def serve_frontend(fallback_path: str):
if fallback_path.startswith("api"):
raise HTTPException(status_code=404, detail="API route not found")
file_path = os.path.join(FRONTEND_DIR, fallback_path)
if os.path.isfile(file_path):
return FileResponse(file_path)
index_path = os.path.join(FRONTEND_DIR, "index.html")
if os.path.isfile(index_path):
return FileResponse(index_path)
raise HTTPException(status_code=404, detail="Frontend file not found")
+1
View File
@@ -4,3 +4,4 @@ motor>=3.3.2
pydantic>=2.6.4
pydantic-settings>=2.2.1
dnspython>=2.6.1
email-validator>=2.1.0
+2
View File
@@ -1,6 +1,7 @@
services:
mongodb:
image: mongo:4.4
platform: linux/amd64
container_name: coffee-mongodb
restart: unless-stopped
ports:
@@ -12,6 +13,7 @@ services:
build:
context: .
dockerfile: Dockerfile
platform: linux/amd64
container_name: coffee-app
restart: unless-stopped
ports: