mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
refactor(media): 🐛 Use hono/proxy in media proxy
Some checks failed
CodeQL Scan / Analyze (javascript-typescript) (push) Failing after 38s
Build Docker Images / lint (push) Successful in 28s
Build Docker Images / check (push) Failing after 5m26s
Build Docker Images / tests (push) Failing after 6s
Build Docker Images / build (server, Dockerfile, ${{ github.repository_owner }}/server) (push) Has been skipped
Build Docker Images / build (worker, Worker.Dockerfile, ${{ github.repository_owner }}/worker) (push) Has been skipped
Deploy Docs to GitHub Pages / build (push) Failing after 14s
Mirror to Codeberg / Mirror (push) Failing after 0s
Deploy Docs to GitHub Pages / Deploy (push) Has been skipped
Nix Build / check (push) Failing after 32m28s
Some checks failed
CodeQL Scan / Analyze (javascript-typescript) (push) Failing after 38s
Build Docker Images / lint (push) Successful in 28s
Build Docker Images / check (push) Failing after 5m26s
Build Docker Images / tests (push) Failing after 6s
Build Docker Images / build (server, Dockerfile, ${{ github.repository_owner }}/server) (push) Has been skipped
Build Docker Images / build (worker, Worker.Dockerfile, ${{ github.repository_owner }}/worker) (push) Has been skipped
Deploy Docs to GitHub Pages / build (push) Failing after 14s
Mirror to Codeberg / Mirror (push) Failing after 0s
Deploy Docs to GitHub Pages / Deploy (push) Has been skipped
Nix Build / check (push) Failing after 32m28s
This commit is contained in:
parent
3fe9926fcf
commit
d4afd84019
|
|
@ -1,5 +1,6 @@
|
||||||
import { apiRoute } from "@/api";
|
import { apiRoute } from "@/api";
|
||||||
import { createRoute, z } from "@hono/zod-openapi";
|
import { createRoute, z } from "@hono/zod-openapi";
|
||||||
|
import { proxy } from "hono/proxy";
|
||||||
import type { ContentfulStatusCode, StatusCode } from "hono/utils/http-status";
|
import type { ContentfulStatusCode, StatusCode } from "hono/utils/http-status";
|
||||||
import { ApiError } from "~/classes/errors/api-error";
|
import { ApiError } from "~/classes/errors/api-error";
|
||||||
import { config } from "~/packages/config-manager";
|
import { config } from "~/packages/config-manager";
|
||||||
|
|
@ -53,10 +54,7 @@ export default apiRoute((app) =>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const media = await fetch(id, {
|
const media = await proxy(id, {
|
||||||
headers: {
|
|
||||||
"Accept-Encoding": "br",
|
|
||||||
},
|
|
||||||
// @ts-expect-error Proxy is a Bun-specific feature
|
// @ts-expect-error Proxy is a Bun-specific feature
|
||||||
proxy: config.http.proxy.address,
|
proxy: config.http.proxy.address,
|
||||||
});
|
});
|
||||||
|
|
@ -84,10 +82,8 @@ export default apiRoute((app) =>
|
||||||
media.headers.get("Content-Type") || "application/octet-stream",
|
media.headers.get("Content-Type") || "application/octet-stream",
|
||||||
"Content-Length": media.headers.get("Content-Length") || "0",
|
"Content-Length": media.headers.get("Content-Length") || "0",
|
||||||
"Content-Security-Policy": "",
|
"Content-Security-Policy": "",
|
||||||
"Content-Encoding": "",
|
|
||||||
// Real filename
|
// Real filename
|
||||||
"Content-Disposition": `inline; filename="${realFilename}"`,
|
"Content-Disposition": `inline; filename="${realFilename}"`,
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: Hono doesn't type this response so this has a TS error
|
});
|
||||||
}) as any;
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue