import { fetch } from "https://esm.town/v/std/fetch";
export default async function(request: Request) {
const url = new URL(request.url);
const h = url.searchParams.get("tdestination");
if (h) {
const resp = await fetch(decodeURIComponent(url.searchParams.get("tdestination")), {
method: request.method,
body: request.body,
headers: request.headers,
redirect: "manual",
});
return new Response(resp.body, { status: resp.status, headers: resp.headers });
}
else {
const resp = await fetch(decodeURIComponent(url.searchParams.get("destination")), {
method: request.method,
body: request.body,
headers: request.headers,
});
return new Response(resp.body, { status: resp.status, headers: resp.headers });
}
}