Skip to content

Commit

Permalink
fix: fix cloudflare home
Browse files Browse the repository at this point in the history
  • Loading branch information
adams549659584 committed May 29, 2023
1 parent db188a6 commit d39376c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cloudflare/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,18 @@ const getRandomIP = () => {
* @returns
*/
const home = async (pathname) => {
let url = `https://raw.githubusercontent.com/adams549659584/go-proxy-bingai/master/cloudflare/index.html`;
const baseUrl = 'https://raw.githubusercontent.com/adams549659584/go-proxy-bingai/master/';
let url;
// if (pathname.startsWith('/github/')) {
if (pathname.indexOf('/github/') === 0) {
url = pathname.replace('/github/', 'https://raw.githubusercontent.com/adams549659584/go-proxy-bingai/master/');
} else {
url = baseUrl + 'cloudflare/index.html';
}
const res = await fetch(url);
const newRes = new Response(res.body, res);
if (pathname === '/') {
newRes.headers.delete('content-security-policy');
newRes.headers.set('content-type', 'text/html; charset=utf-8');
}
return newRes;
Expand Down

0 comments on commit d39376c

Please sign in to comment.