mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
add workers for bingAI
This commit is contained in:
parent
95c5410f00
commit
441db3a1f4
4 changed files with 38 additions and 9 deletions
29
en/searchurl/cloudflare/bing.js
Normal file
29
en/searchurl/cloudflare/bing.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
export default {
|
||||
async fetch(req, _env) {
|
||||
let url = req.url;
|
||||
let iSlash = url.indexOf('/',11);
|
||||
let nUrl = "https://www.bing.com/"+url.substring(iSlash+1);
|
||||
return goUrl(req, nUrl);
|
||||
}
|
||||
}
|
||||
|
||||
function goUrl(request, url) {
|
||||
//构建 fetch 参数
|
||||
let fp = {
|
||||
method: request.method,
|
||||
headers: {}
|
||||
}
|
||||
//保留头部信息
|
||||
let reqHeaders = new Headers(request.headers);
|
||||
let dropHeaders = ["cookie","user-agent","accept","accept-language"];
|
||||
let he = reqHeaders.entries();
|
||||
for (let h of he) {
|
||||
let key = h[0],
|
||||
value = h[1];
|
||||
if (dropHeaders.includes(key)) {
|
||||
fp.headers[key] = value;
|
||||
}
|
||||
}
|
||||
return fetch(url, fp);
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue