diff --git a/backend/app/routers/auth.py b/backend/app/routers/auth.py index cf06038..3f26f55 100644 --- a/backend/app/routers/auth.py +++ b/backend/app/routers/auth.py @@ -13,8 +13,8 @@ from app.schemas.user import UserCreate, UserUpdate, UserResponse, Token from app.services.auth import get_password_hash, verify_password, create_access_token from app.dependencies import get_current_user -# Avatar upload directory -UPLOAD_DIR = Path("uploads/avatars") +# Avatar upload directory (absolute path to ensure consistency) +UPLOAD_DIR = Path("/app/uploads/avatars") UPLOAD_DIR.mkdir(parents=True, exist_ok=True) ALLOWED_EXTENSIONS = {".jpg", ".jpeg", ".png", ".gif", ".webp"} @@ -134,6 +134,9 @@ async def upload_avatar( filename = f"{current_user.id}_{uuid.uuid4().hex}{ext}" file_path = UPLOAD_DIR / filename + # Ensure directory exists (may be missing after volume recreate) + UPLOAD_DIR.mkdir(parents=True, exist_ok=True) + with open(file_path, "wb") as f: f.write(content)