fix: return image/apng media type from animated card endpoint (#196) #204

Merged
cal merged 3 commits from issue/196-bug-apng-endpoint-returns-wrong-media-type-image-p into main 2026-04-08 02:26:05 +00:00

View File

@ -770,7 +770,7 @@ async def get_animated_card(
headers = {"Cache-Control": "public, max-age=86400"}
if os.path.isfile(cache_path) and tier is None:
return FileResponse(path=cache_path, media_type="image/png", headers=headers)
return FileResponse(path=cache_path, media_type="image/apng", headers=headers)

BLOCKING: This cache-hit return path also needs media_type="image/apng". It serves the same APNG file but still returns the wrong MIME type. Since most production requests hit this path after first render, the fix at line 863 will almost never take effect.

**BLOCKING**: This cache-hit return path also needs `media_type="image/apng"`. It serves the same APNG file but still returns the wrong MIME type. Since most production requests hit this path after first render, the fix at line 863 will almost never take effect.
all_pos = (
CardPosition.select()
@ -860,7 +860,7 @@ async def get_animated_card(
finally:
await page.close()
return FileResponse(path=cache_path, media_type="image/png", headers=headers)
return FileResponse(path=cache_path, media_type="image/apng", headers=headers)
@router.get("/{player_id}/{card_type}card")