fix: fix cloudflare home
parent
90df9416f9
commit
db188a6da2
|
@ -3,9 +3,9 @@
|
|||
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
|
||||
<link rel="icon" type="image/svg+xml" href="https://gitee.com/adams549659584/go-proxy-bingai/raw/master/frontend/public/img/logo.svg" />
|
||||
<link rel="icon" type="image/svg+xml" href="/github/frontend/public/img/logo.svg" />
|
||||
<meta content="yes" name="apple-mobile-web-app-capable" />
|
||||
<link rel="apple-touch-icon" href="https://gitee.com/adams549659584/go-proxy-bingai/raw/master/frontend/public/img/pwa/logo-192.png">
|
||||
<link rel="apple-touch-icon" href="/github/frontend/public/img/pwa/logo-192.png">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover" />
|
||||
<meta name="referrer" content="origin-when-cross-origin" />
|
||||
|
@ -41,7 +41,7 @@
|
|||
class="relative bg-white px-6 pb-8 pt-10 shadow-xl ring-1 ring-gray-900/5 sm:mx-auto sm:max-w-lg sm:rounded-lg sm:px-10 lg:max-w-3xl">
|
||||
<div class="mx-auto max-w-3xl">
|
||||
<div class="flex justify-center">
|
||||
<img src="https://gitee.com/adams549659584/go-proxy-bingai/raw/master/frontend/public/img/logo.svg" class="h-24" alt="BingAI" />
|
||||
<img src="/github/frontend/public/img/logo.svg" class="h-24" alt="BingAI" />
|
||||
</div>
|
||||
<div class="mt-6 text-center text-3xl text-gray-600">聊天服务器已部署完成</div>
|
||||
<div class="divide-y divide-gray-300/50">
|
||||
|
|
|
@ -70,10 +70,22 @@ const getRandomIP = () => {
|
|||
return randomIP;
|
||||
};
|
||||
|
||||
const home = async () => {
|
||||
const res = await fetch('https://raw.githubusercontent.com/adams549659584/go-proxy-bingai/master/cloudflare/index.html');
|
||||
/**
|
||||
* home
|
||||
* @param {string} pathname
|
||||
* @returns
|
||||
*/
|
||||
const home = async (pathname) => {
|
||||
let url = `https://raw.githubusercontent.com/adams549659584/go-proxy-bingai/master/cloudflare/index.html`;
|
||||
// if (pathname.startsWith('/github/')) {
|
||||
if (pathname.indexOf('/github/') === 0) {
|
||||
url = pathname.replace('/github/', 'https://raw.githubusercontent.com/adams549659584/go-proxy-bingai/master/');
|
||||
}
|
||||
const res = await fetch(url);
|
||||
const newRes = new Response(res.body, res);
|
||||
newRes.headers.set('content-type', 'text/html; charset=utf-8');
|
||||
if (pathname === '/') {
|
||||
newRes.headers.set('content-type', 'text/html; charset=utf-8');
|
||||
}
|
||||
return newRes;
|
||||
};
|
||||
|
||||
|
@ -87,8 +99,9 @@ export default {
|
|||
*/
|
||||
async fetch(request, env, ctx) {
|
||||
const currentUrl = new URL(request.url);
|
||||
if (currentUrl.pathname === '/') {
|
||||
return home();
|
||||
// if (currentUrl.pathname === '/' || currentUrl.pathname.startsWith('/github/')) {
|
||||
if (currentUrl.pathname === '/' || currentUrl.pathname.indexOf('/github/') === 0) {
|
||||
return home(currentUrl.pathname);
|
||||
}
|
||||
const targetUrl = new URL(SYDNEY_ORIGIN + currentUrl.pathname + currentUrl.search);
|
||||
|
||||
|
|
Loading…
Reference in New Issue