cloudfucked

This commit is contained in:
2025-04-26 11:22:09 -04:00
commit 8c3f23c605
2 changed files with 91 additions and 0 deletions

52
src/index.js Normal file
View File

@@ -0,0 +1,52 @@
export default {
async fetch(request){
const req = new URL(request.url);
const url = req.searchParams.get("p");
const pw = req.searchParams.get("k");
if(
!url ||
!pw ||
pw != "185d7c9bfb0d5b1bd67373f8b4f0a04a85dfa4aa78"
){
return new Response("Fuck off", { status: 404 });
}
// clone headers to send to target
var headers = new Headers(request.headers);
headers.delete("host");
try{
const proxy_req =
await fetch(
url,
{
method: request.method,
headers: headers,
body: request.method !== "GET" && request.method !== "HEAD" ? await request.text() : undefined,
}
);
// send back proxied headers
const headers_recv = new Headers();
proxy_req.headers.forEach(function(value, key){
headers_recv.set(key, value);
});
const proxy_res = await proxy_req.arrayBuffer();
return new Response(proxy_res, {
status: proxy_req.status,
statusText: proxy_req.statusText,
headers: headers_recv
});
}catch(err){
return new Response(err.toString(), { status: 400 });
}
}
};