fix
This commit is contained in:
parent
e20ea7abaf
commit
6077684a91
|
|
@ -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<string, string>;
|
||||
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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue