diff --git a/app/main.py b/app/main.py index 64e9fb9..0fe2600 100644 --- a/app/main.py +++ b/app/main.py @@ -50,8 +50,10 @@ async def health(): # Serve static frontend (will be mounted if exists) FRONTEND_DIR = "/app/frontend" -if os.path.exists(FRONTEND_DIR): - app.mount("/assets", StaticFiles(directory=f"{FRONTEND_DIR}/assets"), name="assets") +ASSETS_DIR = f"{FRONTEND_DIR}/assets" + +if os.path.exists(FRONTEND_DIR) and os.path.exists(ASSETS_DIR): + app.mount("/assets", StaticFiles(directory=ASSETS_DIR), name="assets") @app.get("/") async def serve_frontend(): @@ -59,17 +61,19 @@ if os.path.exists(FRONTEND_DIR): @app.get("/{path:path}") async def serve_spa(path: str): + if path.startswith("api/"): + return None # Let API routes handle file_path = f"{FRONTEND_DIR}/{path}" if os.path.exists(file_path) and os.path.isfile(file_path): return FileResponse(file_path) return FileResponse(f"{FRONTEND_DIR}/index.html") -else: - # Fallback: serve basic info page - @app.get("/") - async def root(): - return { - "service": settings.APP_NAME, - "version": settings.APP_VERSION, - "docs": "/api/docs", - "health": "/api/health" - } + +# Fallback: serve basic info page when no frontend +@app.get("/") +async def root(): + return { + "service": settings.APP_NAME, + "version": settings.APP_VERSION, + "docs": "/api/docs", + "health": "/api/health" + }