Enhance logging for mobile requests in log-requests middleware
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 44s

Add functionality to log all requests from mobile devices, improving debugging capabilities. Extend the existing passkey endpoint checks to include a new endpoint for cross-device registration. This update aims to provide clearer insights into mobile user interactions with the application.
This commit is contained in:
Torsten Schulz (local)
2026-01-08 23:42:16 +01:00
parent e0c41b76c3
commit e1c555e99f
2 changed files with 153 additions and 3 deletions

View File

@@ -19,14 +19,16 @@ export default defineEventHandler((event) => {
'/api/auth/passkeys/register',
'/api/auth/passkeys/authentication-options',
'/api/auth/passkeys/login',
'/api/auth/passkeys/recovery'
'/api/auth/passkeys/recovery',
'/passkey-register-cross-device'
]
const isPasskeyEndpoint = passkeyEndpoints.some(ep => path.startsWith(ep))
// Logge auch alle Requests vom Smartphone (Mobile User-Agent)
const isMobile = /Mobile|Android|iPhone|iPad/i.test(userAgent || '')
const isPasskeyEndpoint = passkeyEndpoints.some(ep => path.startsWith(ep)) || (isMobile && path.startsWith('/'))
if (isPasskeyEndpoint) {
const timestamp = new Date().toISOString()
const isMobile = /Mobile|Android|iPhone|iPad/i.test(userAgent || '')
console.log('')
console.log('─'.repeat(80))
@@ -51,6 +53,12 @@ export default defineEventHandler((event) => {
console.log(`[REQUEST] ⚠️ Wenn dieser Request vom Smartphone kommt, sollte der User-Agent Mobile/Android/iPhone enthalten`)
}
// Logge alle Requests vom Smartphone (für Debugging)
if (isMobile && path.startsWith('/') && !path.startsWith('/_nuxt') && !path.startsWith('/api')) {
console.log(`[REQUEST] 📱 SMARTPHONE REQUEST - ${path}`)
console.log(`[REQUEST] ⚠️ Wenn das Smartphone die Website öffnet, sollten hier Requests erscheinen`)
}
console.log('─'.repeat(80))
console.log('')
}