import { getConfig } from '../data/config.js'; async function handleDebug(request, env) { try { const url = new URL(request.url); const config = await getConfig(env); const debugInfo = { timestamp: new Date().toISOString(), pathname: url.pathname, kvBinding: !!env.SUBSCRIPTIONS_KV, configExists: !!config, adminUsername: config.ADMIN_USERNAME, hasJwtSecret: !!config.JWT_SECRET, jwtSecretLength: config.JWT_SECRET ? config.JWT_SECRET.length : 0 }; return new Response(`
时间: ${debugInfo.timestamp}
路径: ${debugInfo.pathname}
KV绑定: ${debugInfo.kvBinding ? '✓' : '✗'}
配置存在: ${debugInfo.configExists ? '✓' : '✗'}
管理员用户名: ${String(debugInfo.adminUsername || '').replace(//g, '>')}
JWT密钥: ${debugInfo.hasJwtSecret ? '✓' : '✗'} (长度: ${debugInfo.jwtSecretLength})