From 6077684a91de4307986a59e642c7fc14d9a0e747 Mon Sep 17 00:00:00 2001 From: Rizky Date: Wed, 17 Apr 2024 19:05:24 +0700 Subject: [PATCH] fix --- pkgs/api/_proxy.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkgs/api/_proxy.ts b/pkgs/api/_proxy.ts index 4f2d7f5..9bb9bd6 100644 --- a/pkgs/api/_proxy.ts +++ b/pkgs/api/_proxy.ts @@ -1,13 +1,14 @@ import { apiContext } from "service-srv"; export const _ = { - url: "/_proxy/*", + url: "/_proxy/**", raw: true, async api() { const { req } = apiContext(this); try { - const url = new URL(decodeURIComponent(req.params["_"])); + const raw_url = decodeURIComponent(req.params["_"]); + const url = new URL(raw_url) as URL; const body = await req.arrayBuffer(); const headers = {} as Record; req.headers.forEach((v, k) => { @@ -18,11 +19,17 @@ export const _ = { headers[k] = v; }); - return await fetch(url, { + const res = await fetch(url, { method: req.method || "POST", headers, body, }); + + if (res.headers.get("content-encoding")) { + res.headers.delete("content-encoding"); + } + + return res; } catch (e: any) { console.error(e); new Response(