feat: media routing

This commit is contained in:
nihonium 2025-12-06 09:17:45 +03:00
parent eef3696e5e
commit 7787eb328f
Signed by: nihonium
GPG key ID: 0251623741027CFC
2 changed files with 11 additions and 1 deletions

View file

@ -28,6 +28,16 @@ server {
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade; proxy_cache_bypass $http_upgrade;
} }
location /media/ {
rewrite ^/media/(.*)$ /$1 break;
proxy_pass http://nyanimedb-images:8000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
#error_page 404 /404.html; #error_page 404 /404.html;
error_page 500 502 503 504 /50x.html; error_page 500 502 503 504 /50x.html;

View file

@ -99,7 +99,7 @@ async def download_by_url(payload: DownloadByUrlRequest):
return {"path": rel} return {"path": rel}
@app.get("/media/{path:path}") @app.get("/{path:path}")
async def get_image(path: str): async def get_image(path: str):
""" """
Отдаёт файл по относительному пути (например, posters/ab/cd/hash.jpg). Отдаёт файл по относительному пути (например, posters/ab/cd/hash.jpg).