uweb/en/searchurl/deno/bing.js

25 lines
640 B
JavaScript
Raw Normal View History

2023-04-10 00:23:51 +00:00
import { serve } from "https://deno.land/std/http/server.ts";
2023-04-07 13:38:56 +00:00
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);