Added: Extra media endpoint for cors

This commit is contained in:
Luc Mcgrady 2025-11-18 21:34:59 +00:00
parent 06a4cd1916
commit 73f161088f
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C
2 changed files with 3 additions and 1 deletions

View file

@ -62,6 +62,7 @@ flask_cors.CORS(
r"/_anki/js/vendor/mathjax/output/chtml/fonts/woff-v2/.*.woff": {
"origins": "*"
},
r"/media/.*": {"origins": "*"},
r"/*": {"origins": "127.0.0.1"},
},
)
@ -481,6 +482,7 @@ def _extract_request(
if not aqt.mw.col:
return NotFound(message=f"collection not open, ignore request for {path}")
path = path.removeprefix("media/")
path = hooks.media_file_filter(path)
return LocalFileRequest(root=aqt.mw.col.media.dir(), path=path)

View file

@ -101,7 +101,7 @@ addEventListener("keydown", (e) => {
});
const base = document.createElement("base");
base.href = "/";
base.href = "/media/";
document.head.appendChild(base);
function pycmd(cmd: string) {