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,