mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
25 lines
640 B
JavaScript
25 lines
640 B
JavaScript
import { serve } from "https://deno.land/std/http/server.ts";
|
|
async function handler(req: Request): Promise<Response> {
|
|
let url = req.url;
|
|
let iSlash = url.indexOf('/',11);
|
|
let nUrl = "https://www.bing.com/"+url.substring(iSlash+1);
|
|
let fp = {
|
|
method: req.method,
|
|
headers: {}
|
|
}
|
|
let reqHeaders = new Headers(req.headers);
|
|
let keepHeaders = ["cookie","user-agent","accept","accept-language"];
|
|
let he = reqHeaders.entries();
|
|
for (let h of he) {
|
|
let key = h[0],
|
|
value = h[1];
|
|
if (keepHeaders.includes(key)) {
|
|
fp.headers[key] = value;
|
|
}
|
|
}
|
|
|
|
return await fetch(nUrl, fp);
|
|
}
|
|
|
|
serve(handler);
|