fix(api): 🐛 Attempt 2 at fixing proxy bug

This commit is contained in:
Jesse Wierzbinski 2024-06-05 16:07:56 -10:00
parent 29b98fd1d1
commit a319d1e628
No known key found for this signature in database

View file

@ -1,5 +1,5 @@
import { applyConfig, handleZodError } from "@/api"; import { applyConfig, handleZodError } from "@/api";
import { errorResponse } from "@/response"; import { errorResponse, response } from "@/response";
import { zValidator } from "@hono/zod-validator"; import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono"; import type { Hono } from "hono";
import { z } from "zod"; import { z } from "zod";
@ -39,12 +39,18 @@ export default (app: Hono) =>
400, 400,
); );
const media = fetch(id, { const media = await fetch(id, {
headers: { headers: {
...context.req.raw.headers, "Accept-Encoding": "identity",
}, },
}); });
return media; return response(media.body, media.status, {
"Content-Type":
media.headers.get("Content-Type") ||
"application/octet-stream",
"Content-Length": media.headers.get("Content-Length") || "0",
"Content-Security-Policy": "",
});
}, },
); );