This commit is contained in:
Iliyan Angelov
2025-12-03 01:31:34 +02:00
parent e32527ae8c
commit 5fb50983a9
37 changed files with 5844 additions and 201 deletions

View File

@@ -246,8 +246,22 @@ async def serve_upload_file(file_path: str, request: Request):
# Get origin from request
origin = request.headers.get('origin')
# Prepare response
response = FileResponse(str(file_location))
# Determine media type based on file extension
media_type = None
file_ext = file_location.suffix.lower()
if file_ext == '.webp':
media_type = 'image/webp'
elif file_ext in ['.jpg', '.jpeg']:
media_type = 'image/jpeg'
elif file_ext == '.png':
media_type = 'image/png'
elif file_ext == '.gif':
media_type = 'image/gif'
elif file_ext == '.ico':
media_type = 'image/x-icon'
# Prepare response with appropriate media type
response = FileResponse(str(file_location), media_type=media_type)
# Add CORS headers if origin matches
if origin: