Add CORS support to MCP server and tools; enhance image URL handling in tools

This commit is contained in:
hlohaus 2025-11-02 07:31:28 +01:00
parent 5d53e58d2c
commit a492352901
4 changed files with 29 additions and 12 deletions

View file

@ -356,11 +356,13 @@ class Backend_Api(Api):
if response.startswith("/media/"):
media_dir = get_media_dir()
filename = os.path.basename(response.split("?")[0])
try:
return send_from_directory(os.path.abspath(media_dir), filename)
finally:
if not cache_id:
if not cache_id:
try:
return send_from_directory(os.path.abspath(media_dir), filename)
finally:
os.remove(os.path.join(media_dir, filename))
else:
return redirect(response)
elif response.startswith("https://") or response.startswith("http://"):
return redirect(response)
if do_filter: