fix: correct static file mount order and update architecture validator
- Fix FastAPI static mount order: module statics must come BEFORE main
/static mount, otherwise the more general mount catches all requests
- Update validate_architecture.py to check self-contained module paths:
- JS files in app/modules/*/static/{admin,vendor}/js/
- Templates in app/modules/*/templates/*/{admin,vendor}/
- TPL-010 now finds module JS files for Alpine variable checking
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
16
main.py
16
main.py
@@ -178,13 +178,10 @@ logger.info("=" * 80)
|
||||
# ========================================
|
||||
# MOUNT STATIC FILES - Use absolute path
|
||||
# ========================================
|
||||
if STATIC_DIR.exists():
|
||||
app.mount("/static", StaticFiles(directory=str(STATIC_DIR)), name="static")
|
||||
logger.info(f"Mounted static files from: {STATIC_DIR}")
|
||||
else:
|
||||
logger.warning(f"Static directory not found at {STATIC_DIR}")
|
||||
# NOTE: Mount order matters in FastAPI - more specific paths must come FIRST
|
||||
# Module static files must be mounted before the main /static mount
|
||||
|
||||
# Mount module static files (self-contained modules)
|
||||
# Mount module static files FIRST (self-contained modules)
|
||||
MODULES_DIR = BASE_DIR / "app" / "modules"
|
||||
if MODULES_DIR.exists():
|
||||
for module_dir in sorted(MODULES_DIR.iterdir()):
|
||||
@@ -197,6 +194,13 @@ if MODULES_DIR.exists():
|
||||
app.mount(mount_path, StaticFiles(directory=str(module_static)), name=f"{module_name}_static")
|
||||
logger.info(f"Mounted module static files: {mount_path} -> {module_static}")
|
||||
|
||||
# Mount main static directory AFTER module statics
|
||||
if STATIC_DIR.exists():
|
||||
app.mount("/static", StaticFiles(directory=str(STATIC_DIR)), name="static")
|
||||
logger.info(f"Mounted static files from: {STATIC_DIR}")
|
||||
else:
|
||||
logger.warning(f"Static directory not found at {STATIC_DIR}")
|
||||
|
||||
# Mount uploads directory for user-uploaded media files
|
||||
UPLOADS_DIR = BASE_DIR / "uploads"
|
||||
if UPLOADS_DIR.exists():
|
||||
|
||||
Reference in New Issue
Block a user