Commit 88016560 authored by Your Name's avatar Your Name

Fix middleware order so dashboard context runs after session

Middleware execution order was wrong - dashboard context middleware was running
BEFORE SessionMiddleware, so request.session didn't exist yet.

Fixed execution order:
1. ProxyHeadersMiddleware
2. SessionMiddleware
3. CORSMiddleware
4. tier_limit_middleware
5. auth_middleware
6. dashboard_context_middleware
parent acbc4128
......@@ -1690,8 +1690,11 @@ app.add_middleware(SessionMiddleware, secret_key=_session_secret, max_age=30 * 2
# This ensures proxy headers are processed before any other middleware (including auth_middleware)
app.add_middleware(ProxyHeadersMiddleware)
# Add dashboard context middleware LAST so it executes FIRST
# This ensures context variables are available to all template renders
app.add_middleware(dashboard_context_middleware)
# Dashboard context middleware - adds is_aisbf_cloud and welcome_shown to all template contexts
@app.middleware("http")
async def dashboard_context_middleware(request: Request, call_next):
if request.url.path.startswith("/dashboard") and 'session' in request.scope:
# ALWAYS set is_aisbf_cloud for ALL dashboard paths (to show footer links everywhere)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment