From 8c61c28b7dacff60aea9739b52032a9681d3aa10 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Fri, 20 Mar 2026 23:28:13 -0400 Subject: [PATCH] fix: mount /static before ui.router to prevent wildcard route catching static files The ui.router's /{username}/{persona} wildcard was matching /static/style.css (username="static", persona="style.css") because app.mount("/static") was registered after app.include_router(ui.router). FastAPI processes routes in registration order, so /static must be mounted first. Co-Authored-By: Claude Sonnet 4.6 --- cortex/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cortex/main.py b/cortex/main.py index 09fbfc7..f28718f 100644 --- a/cortex/main.py +++ b/cortex/main.py @@ -35,14 +35,16 @@ app.include_router(distill.router) app.include_router(auth.router) app.include_router(orchestrator.router) +# Static files — must be mounted BEFORE ui.router so /static/* is matched first. +# ui.router has a wildcard /{username}/{persona} that would otherwise catch /static/style.css etc. +app.mount("/static", StaticFiles(directory="static"), name="static") + # Onboarding (invite tokens + persona creation — before ui.router) app.include_router(onboarding.router) # UI router (login + /{user}/{persona} — must be last to avoid swallowing API paths) app.include_router(ui.router) -app.mount("/static", StaticFiles(directory="static"), name="static") - @app.get("/health") async def health() -> dict: