From a8293063a5e940104eae698b8ea7a232f7bc1714 Mon Sep 17 00:00:00 2001 From: noirscape Date: Sun, 9 Feb 2025 17:38:40 +0100 Subject: [PATCH] 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 . --- maloja/server.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/maloja/server.py b/maloja/server.py index c76d9a9..35ae5b3 100644 --- a/maloja/server.py +++ b/maloja/server.py @@ -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/") 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():