Enhance debug logging for Passkey Registration requests
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 51s

Improve logging in the register-passkey-options and log-requests middleware to provide detailed insights into request handling. Add user-agent analysis, IP address logging, and mobile/desktop detection to aid in troubleshooting. This update aims to enhance the clarity of request logs and support better debugging during the Passkey registration process.
This commit is contained in:
Torsten Schulz (local)
2026-01-08 23:33:04 +01:00
parent eae2889f37
commit e0c41b76c3
2 changed files with 38 additions and 9 deletions

View File

@@ -16,14 +16,27 @@ export default defineEventHandler(async (event) => {
const nodeEnv = process.env.NODE_ENV || 'development'
// Debug-Ausgaben immer ausgeben (nicht nur in dev)
console.log('[DEBUG] register-passkey-options request received', {
origin: requestOrigin,
userAgent: userAgent?.substring(0, 100),
console.log('')
console.log('='.repeat(80))
console.log('[DEBUG] 📋 ===== REGISTRATION OPTIONS REQUEST RECEIVED =====')
console.log('='.repeat(80))
console.log('[DEBUG] Request Details:', {
origin: requestOrigin || 'none',
userAgent: userAgent?.substring(0, 150) || 'none',
method: getMethod(event),
timestamp: new Date().toISOString(),
nodeEnv: nodeEnv,
pid: process.pid
pid: process.pid,
ip: getHeader(event, 'x-forwarded-for') || getHeader(event, 'x-real-ip') || 'unknown',
note: 'Dieser Request kommt vom Desktop-Browser, wenn der QR-Code generiert wird'
})
console.log('[DEBUG] User-Agent Analysis:', {
isMobile: /Mobile|Android|iPhone|iPad/i.test(userAgent || ''),
isDesktop: !/Mobile|Android|iPhone|iPad/i.test(userAgent || ''),
browser: userAgent?.substring(0, 100)
})
console.log('='.repeat(80))
console.log('')
const body = await readBody(event)
const name = String(body?.name || '').trim()