fix: load configuration from config.json and fix authentication
- Load anime_directory and master_password_hash from config.json on startup - Sync configuration from config.json to settings object in fastapi_app.py - Update dependencies.py to load config from JSON if not in environment - Fix app.js to use makeAuthenticatedRequest() for all authenticated API calls - Fix API endpoint paths from /api/v1/anime to /api/anime - Update auth_service.py to load master_password_hash from config.json - Update auth.py setup endpoint to save master_password_hash to config - Fix rate limiting code to satisfy type checker - Update config.json with test master password hash Fixes: - 401 Unauthorized errors on /api/anime endpoint - 503 Service Unavailable errors on /api/anime/process/locks - Configuration not being loaded from config.json file - Authentication flow now works end-to-end with JWT tokens
This commit is contained in:
@@ -53,10 +53,30 @@ async def lifespan(app: FastAPI):
|
||||
"""Manage application lifespan (startup and shutdown)."""
|
||||
# Startup
|
||||
try:
|
||||
# Load configuration from config.json and sync with settings
|
||||
try:
|
||||
from src.server.services.config_service import get_config_service
|
||||
config_service = get_config_service()
|
||||
config = config_service.load_config()
|
||||
|
||||
# Sync anime_directory from config.json to settings
|
||||
if config.other and config.other.get("anime_directory"):
|
||||
settings.anime_directory = str(config.other["anime_directory"])
|
||||
print(
|
||||
f"Loaded anime_directory from config: "
|
||||
f"{settings.anime_directory}"
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Warning: Failed to load config from config.json: {e}")
|
||||
|
||||
# Initialize SeriesApp with configured directory and store it on
|
||||
# application state so it can be injected via dependencies.
|
||||
if settings.anime_directory:
|
||||
app.state.series_app = SeriesApp(settings.anime_directory)
|
||||
print(
|
||||
f"SeriesApp initialized with directory: "
|
||||
f"{settings.anime_directory}"
|
||||
)
|
||||
else:
|
||||
# Log warning when anime directory is not configured
|
||||
print(
|
||||
|
||||
Reference in New Issue
Block a user