feat: 添加根路径重定向与日志增强

*   在根路径 '/' 访问时,自动重定向到主页 'https://searchgal.homes'。
*   在 `logToCF` 函数中添加 `console.log`,方便在 Cloudflare 控制台查看日志。
This commit is contained in:
Jurangren
2025-08-22 02:33:33 +08:00
parent 6a59d03ac0
commit 9afdee1cf6
2 changed files with 6 additions and 0 deletions

View File

@@ -54,6 +54,10 @@ export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
const url = new URL(request.url);
if (url.pathname === '/') {
return Response.redirect('https://searchgal.homes', 302);
}
if (request.method === "OPTIONS") {
return new Response(null, { headers: corsHeaders });
}

View File

@@ -44,6 +44,8 @@ export async function fetchClient(
* @param data 要记录的数据对象。
*/
export async function logToCF(data: object) {
// 在此处添加 console.log以便在 Cloudflare 控制台也能看到日志
console.log(JSON.stringify(data));
try {
await fetch("https://log.gal.homes", {
method: "POST",