From 6480b94d783bdf8e378618865184defb35ceb74a Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Mon, 29 Sep 2025 20:51:41 -0700 Subject: [PATCH] support binary files --- src/server.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/server.tsx b/src/server.tsx index 9f85061..d247eab 100644 --- a/src/server.tsx +++ b/src/server.tsx @@ -16,6 +16,7 @@ type Response = { status: number headers: Record, body: string + isBinary?: boolean } type Success = { @@ -77,7 +78,7 @@ app.get("/tunnel", c => { }) }) -app.get("*", async c => { +app.all("*", async c => { const url = new URL(c.req.url) const localhost = url.hostname.endsWith("localhost") const domains = url.hostname.split(".") @@ -107,6 +108,14 @@ app.get("*", async c => { }) }) + if (result.isBinary) { + const buffer = Buffer.from(result.body, 'base64') + return new Response(buffer, { + status: result.status, + headers: result.headers, + }) + } + return new Response(result.body, { status: result.status, headers: result.headers,