mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
add deno/bing.js
This commit is contained in:
parent
441db3a1f4
commit
6a726e893c
2 changed files with 25 additions and 1 deletions
|
@ -84,7 +84,7 @@ The first part [rootDomain] is required and the others are optional. regex is ja
|
|||
|
||||
</div>
|
||||
<p>Last Modified: 7 April 2023<br>
|
||||
add cloudflare/bing.js<br>
|
||||
add bing.js for cf & deno<br>
|
||||
<pre></pre>
|
||||
</p>
|
||||
|
||||
|
|
24
en/searchurl/deno/bing.js
Normal file
24
en/searchurl/deno/bing.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { serve } from "https://deno.land/std@0.140.0/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);
|
Loading…
Reference in a new issue