fix direct file access in container

AuthorKonata <konata@posteo.jp>
Date
Commitf6c1df06205496b9ae3b8b519076badf2ca7c2cc
Parentb37ea28
1 file changed, 2 insertions(+), 5 deletions(-)
▾Mserver/src/index.ts
@@ -53,7 +53,7 @@ const app = new Elysia()
set.status = "OK";
set.headers["content-type"] = fileScan.mimeType;
return new ElysiaFile(filePath);
return Bun.file(filePath);
})
.get("/transcode/*", async ({ request, query, set, params }) => {
const filePath = path.join(musicRoot, decodeURI(params["*"]));
@@ -67,10 +67,7 @@ const app = new Elysia()
return "Forbidden file type";
}
const bitrate = Number.parseInt(query.bitrate) || 96000;
if (
!matchesType(fileScan.mimeType, mediaTypes) ||
!needsTranscoding(await probeFile(filePath), bitrate)
) {
if (!matchesType(fileScan.mimeType, mediaTypes) || !needsTranscoding(await probeFile(filePath), bitrate)) {
set.status = "Temporary Redirect";
set.headers.Location = `/download/${params["*"]}`;
return "No transcoding necessary or probe failed, redirecting to normal endpoint";