mirror of
https://github.com/Moe-Sakura/Wrangler-API.git
synced 2026-03-15 04:13:18 +08:00
feat: 添加根路径重定向与日志增强
* 在根路径 '/' 访问时,自动重定向到主页 'https://searchgal.homes'。 * 在 `logToCF` 函数中添加 `console.log`,方便在 Cloudflare 控制台查看日志。
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user