Read out mimetypes for cached images

On Firefox, because there is no mimetype set when serving the file, it is served up as raw HTML, causing cached images to not be served to the client (as the fetch is aborted early). It doesn't appear to be an issue in Google Chrome.

This commit fixes #349 .
This commit is contained in:
noirscape 2025-02-09 17:38:40 +01:00 committed by GitHub
parent 126d155208
commit a8293063a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,7 @@ import os
from threading import Thread
from importlib import resources
import time
from magic import from_file
# server stuff
@ -154,7 +155,8 @@ def static_image(pth):
@webserver.route("/cacheimages/<uuid>")
def static_proxied_image(uuid):
return static_file(uuid,root=data_dir['cache']('images'))
mimetype = from_file(os.path.join(data_dir['cache']('images'),uuid),True)
return static_file(uuid,root=data_dir['cache']('images'),mimetype=mimetype)
@webserver.route("/login")
def login():