add workers for bingAI

This commit is contained in:
James Feng Cao 2023-04-07 18:07:09 +08:00
parent 95c5410f00
commit 441db3a1f4
4 changed files with 38 additions and 9 deletions

View File

@ -69,12 +69,12 @@
</li>
<li>
<p>response headers, separeded by ';', Ex.:<br>
Access-Control-Allow-Origin;*;Access-Control-Allow-Credentials;true mybing2.xn--xyza.top</p>
Access-Control-Allow-Origin;https://www.bing.com;Access-Control-Allow-Credentials;true mybing.xn--xyza.top</p>
<p>which makes &quot;mybing2.xn--xyza.top&quot; to accept CORS requests with cookies.</p>
</li>
<li>
<p>IP address and response headers, separeded by ';', Ex.:<br>
172.64.80.1;Access-Control-Allow-Origin;https://www.bing.com;Access-Control-Allow-Credentials;true wild-cake-ff77.jamesfengcao.workers.dev</p>
104.21.8.195;Access-Control-Allow-Origin;https://www.bing.com;Access-Control-Allow-Credentials;true uweb.torapp.eu.org</p>
</li>
</ul>
<p><a href="file:///data/data/info.torapp.uweb/files/default.hosts">&quot;default.hosts&quot;</a> blocks whole domain trees including all descedant domains. The domains in the hosts file must be 2 or 3 segment domains, such as &quot;yahoo.com&quot; and &quot;finance.yahoo.com&quot;. If the length of the last 2 segments is less than 7, such as &quot;com.pl&quot;, then it is treated as one segment, so domains like &quot;xxx.xxx.com.pl&quot; are also valid in the hosts file.</p>
@ -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>
hosts to support both ip address and response headers<br>
add cloudflare/bing.js<br>
<pre></pre>
</p>

View 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);
}

View File

@ -3,7 +3,7 @@
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>/en/_posts/</loc>
<lastmod>2023-04-07T15:29:47+08:00</lastmod>
<lastmod>2023-04-07T18:05:06+08:00</lastmod>
<xhtml:link
rel="alternate"
hreflang="zh"
@ -29,7 +29,7 @@
/>
</url><url>
<loc>/en/</loc>
<lastmod>2023-04-07T15:29:47+08:00</lastmod>
<lastmod>2023-04-07T18:05:06+08:00</lastmod>
<xhtml:link
rel="alternate"
hreflang="zh"
@ -55,10 +55,10 @@
/>
</url><url>
<loc>/en/tags/adblock/</loc>
<lastmod>2023-04-07T15:29:47+08:00</lastmod>
<lastmod>2023-04-07T18:05:06+08:00</lastmod>
</url><url>
<loc>/en/adblock_domain/</loc>
<lastmod>2023-04-07T15:29:47+08:00</lastmod>
<lastmod>2023-04-07T18:05:06+08:00</lastmod>
<xhtml:link
rel="alternate"
hreflang="zh"
@ -71,7 +71,7 @@
/>
</url><url>
<loc>/en/tags/</loc>
<lastmod>2023-04-07T15:29:47+08:00</lastmod>
<lastmod>2023-04-07T18:05:06+08:00</lastmod>
<xhtml:link
rel="alternate"
hreflang="zh"

View File

@ -4,7 +4,7 @@
<sitemap>
<loc>en/sitemap.xml</loc>
<lastmod>2023-04-07T15:29:47+08:00</lastmod>
<lastmod>2023-04-07T18:05:06+08:00</lastmod>
</sitemap>