Enhance deployment script and registration components with improved error handling and debug logging
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 55s
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 55s
Update deploy-production.sh to include comprehensive build validation checks, ensuring critical files and directories are present before proceeding. Enhance the registrieren.vue component to conditionally display the window origin and improve debug logging for the registration process. Additionally, add debug information in the register-passkey-options API to capture request details, including environment and process ID, for better troubleshooting capabilities.
This commit is contained in:
@@ -137,28 +137,106 @@ npm install
|
|||||||
|
|
||||||
# 4. Remove old build (but keep data!)
|
# 4. Remove old build (but keep data!)
|
||||||
echo ""
|
echo ""
|
||||||
echo "4. Removing old build output..."
|
echo "4. Cleaning build artifacts..."
|
||||||
|
# Sicherstellen, dass .output vollständig gelöscht wird
|
||||||
|
if [ -d ".output" ]; then
|
||||||
|
echo " Removing .output directory..."
|
||||||
rm -rf .output
|
rm -rf .output
|
||||||
|
# Prüfen, ob wirklich gelöscht wurde
|
||||||
|
if [ -d ".output" ]; then
|
||||||
|
echo "WARNING: .output konnte nicht vollständig gelöscht werden. Versuche erneut..."
|
||||||
|
sleep 2
|
||||||
|
rm -rf .output
|
||||||
|
if [ -d ".output" ]; then
|
||||||
|
echo "ERROR: .output konnte auch nach erneutem Versuch nicht gelöscht werden!"
|
||||||
|
echo "Bitte manuell prüfen und löschen: rm -rf .output"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo " ✓ .output gelöscht"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Auch .nuxt Cache löschen für sauberen Build
|
||||||
|
if [ -d ".nuxt" ]; then
|
||||||
|
echo " Removing .nuxt cache..."
|
||||||
|
rm -rf .nuxt
|
||||||
|
echo " ✓ .nuxt gelöscht"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prüfe, ob node_modules vorhanden ist (für npm run build)
|
||||||
|
if [ ! -d "node_modules" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "WARNING: node_modules fehlt. Installiere Dependencies..."
|
||||||
|
npm install
|
||||||
|
fi
|
||||||
|
|
||||||
# 5. Build
|
# 5. Build
|
||||||
echo ""
|
echo ""
|
||||||
echo "5. Building application..."
|
echo "5. Building application..."
|
||||||
npm run build
|
echo " Running: npm run build"
|
||||||
|
echo " (This may take a few minutes...)"
|
||||||
|
|
||||||
# Prüfe, ob der Build erfolgreich war
|
# Build mit expliziter Fehlerbehandlung
|
||||||
|
if ! npm run build; then
|
||||||
|
echo ""
|
||||||
|
echo "ERROR: Build fehlgeschlagen mit Exit-Code $?"
|
||||||
|
echo "Bitte prüfen Sie die Build-Ausgabe oben auf Fehler."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prüfe, ob der Build erfolgreich war - mehrere Checks
|
||||||
|
echo ""
|
||||||
|
echo " Verifying build output..."
|
||||||
|
|
||||||
|
BUILD_FAILED=0
|
||||||
|
|
||||||
|
# Check 1: _nuxt Verzeichnis
|
||||||
if [ ! -d ".output/public/_nuxt" ]; then
|
if [ ! -d ".output/public/_nuxt" ]; then
|
||||||
echo "ERROR: Build fehlgeschlagen - .output/public/_nuxt Verzeichnis fehlt!"
|
echo "ERROR: .output/public/_nuxt Verzeichnis fehlt!"
|
||||||
echo "Bitte prüfen Sie die Build-Ausgabe auf Fehler."
|
BUILD_FAILED=1
|
||||||
exit 1
|
else
|
||||||
|
NUXT_FILES=$(find .output/public/_nuxt -type f 2>/dev/null | wc -l)
|
||||||
|
echo " ✓ .output/public/_nuxt vorhanden ($NUXT_FILES Dateien)"
|
||||||
|
if [ "$NUXT_FILES" -eq 0 ]; then
|
||||||
|
echo "ERROR: .output/public/_nuxt ist leer!"
|
||||||
|
BUILD_FAILED=1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Prüfe, ob wichtige Dateien vorhanden sind
|
# Check 2: Server index.mjs
|
||||||
if [ ! -f ".output/server/index.mjs" ]; then
|
if [ ! -f ".output/server/index.mjs" ]; then
|
||||||
echo "ERROR: Build fehlgeschlagen - .output/server/index.mjs fehlt!"
|
echo "ERROR: .output/server/index.mjs fehlt!"
|
||||||
|
BUILD_FAILED=1
|
||||||
|
else
|
||||||
|
echo " ✓ .output/server/index.mjs vorhanden"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check 3: Public Verzeichnis
|
||||||
|
if [ ! -d ".output/public" ]; then
|
||||||
|
echo "ERROR: .output/public Verzeichnis fehlt!"
|
||||||
|
BUILD_FAILED=1
|
||||||
|
else
|
||||||
|
echo " ✓ .output/public vorhanden"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check 4: Server Verzeichnis
|
||||||
|
if [ ! -d ".output/server" ]; then
|
||||||
|
echo "ERROR: .output/server Verzeichnis fehlt!"
|
||||||
|
BUILD_FAILED=1
|
||||||
|
else
|
||||||
|
echo " ✓ .output/server vorhanden"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$BUILD_FAILED" -eq 1 ]; then
|
||||||
|
echo ""
|
||||||
|
echo "ERROR: Build-Verifikation fehlgeschlagen!"
|
||||||
|
echo "Bitte führen Sie manuell aus:"
|
||||||
|
echo " rm -rf .output .nuxt"
|
||||||
|
echo " npm run build"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo " Build erfolgreich - .output/public/_nuxt vorhanden"
|
echo " ✓ Build erfolgreich verifiziert"
|
||||||
|
|
||||||
# 6. Restore Production Data (überschreibe Repo-Defaults mit Backup)
|
# 6. Restore Production Data (überschreibe Repo-Defaults mit Backup)
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
@@ -183,7 +183,7 @@
|
|||||||
<div class="space-y-1 text-blue-800">
|
<div class="space-y-1 text-blue-800">
|
||||||
<div><strong>Challenge:</strong> <code class="bg-blue-100 px-1 rounded">{{ debugChallenge.substring(0, 40) }}...</code></div>
|
<div><strong>Challenge:</strong> <code class="bg-blue-100 px-1 rounded">{{ debugChallenge.substring(0, 40) }}...</code></div>
|
||||||
<div><strong>RP-ID:</strong> <code class="bg-blue-100 px-1 rounded">{{ debugRpId }}</code></div>
|
<div><strong>RP-ID:</strong> <code class="bg-blue-100 px-1 rounded">{{ debugRpId }}</code></div>
|
||||||
<div><strong>Origin:</strong> <code class="bg-blue-100 px-1 rounded">{{ window.location.origin }}</code></div>
|
<div><strong>Origin:</strong> <code class="bg-blue-100 px-1 rounded">{{ typeof window !== 'undefined' ? window.location.origin : 'N/A (SSR)' }}</code></div>
|
||||||
<div class="mt-2 text-blue-700">
|
<div class="mt-2 text-blue-700">
|
||||||
<strong>Hinweis:</strong> Der QR-Code wird vom Browser generiert.
|
<strong>Hinweis:</strong> Der QR-Code wird vom Browser generiert.
|
||||||
Prüfe in der Browser-Konsole (F12) für vollständige Debug-Ausgaben.
|
Prüfe in der Browser-Konsole (F12) für vollständige Debug-Ausgaben.
|
||||||
@@ -513,12 +513,33 @@ const handleRegisterWithPasskey = async () => {
|
|||||||
const timeoutWarning = setTimeout(() => {
|
const timeoutWarning = setTimeout(() => {
|
||||||
console.warn('[DEBUG] startRegistration still waiting after 2 minutes. This might be a Cross-Device timeout.')
|
console.warn('[DEBUG] startRegistration still waiting after 2 minutes. This might be a Cross-Device timeout.')
|
||||||
console.warn('[DEBUG] Make sure your smartphone can reach the server and CORS is configured correctly.')
|
console.warn('[DEBUG] Make sure your smartphone can reach the server and CORS is configured correctly.')
|
||||||
console.warn('[DEBUG] Current origin:', window.location.origin)
|
console.warn('[DEBUG] Current origin:', typeof window !== 'undefined' ? window.location.origin : 'N/A')
|
||||||
console.warn('[DEBUG] Challenge:', pre.options?.challenge)
|
console.warn('[DEBUG] Challenge:', pre.options?.challenge)
|
||||||
}, 120000)
|
}, 120000)
|
||||||
|
|
||||||
|
// Stelle sicher, dass die Options korrekt formatiert sind
|
||||||
|
// @simplewebauthn/browser v13+ erwartet die Options direkt als Objekt
|
||||||
|
const registrationOptions = {
|
||||||
|
challenge: pre.options.challenge,
|
||||||
|
rp: pre.options.rp,
|
||||||
|
user: pre.options.user,
|
||||||
|
pubKeyCredParams: pre.options.pubKeyCredParams,
|
||||||
|
timeout: pre.options.timeout,
|
||||||
|
attestation: pre.options.attestation || 'none',
|
||||||
|
excludeCredentials: pre.options.excludeCredentials || [],
|
||||||
|
authenticatorSelection: pre.options.authenticatorSelection,
|
||||||
|
extensions: pre.options.extensions || {}
|
||||||
|
}
|
||||||
|
|
||||||
console.log('[DEBUG] startRegistration called - QR-Code should appear now (if Cross-Device)')
|
console.log('[DEBUG] startRegistration called - QR-Code should appear now (if Cross-Device)')
|
||||||
credential = await mod.startRegistration(pre.options)
|
console.log('[DEBUG] Registration options structure:', {
|
||||||
|
hasChallenge: !!registrationOptions.challenge,
|
||||||
|
hasRp: !!registrationOptions.rp,
|
||||||
|
hasUser: !!registrationOptions.user,
|
||||||
|
timeout: registrationOptions.timeout
|
||||||
|
})
|
||||||
|
|
||||||
|
credential = await mod.startRegistration(registrationOptions)
|
||||||
|
|
||||||
clearTimeout(timeoutWarning)
|
clearTimeout(timeoutWarning)
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,16 @@ export default defineEventHandler(async (event) => {
|
|||||||
const requestStart = Date.now()
|
const requestStart = Date.now()
|
||||||
const requestOrigin = getHeader(event, 'origin')
|
const requestOrigin = getHeader(event, 'origin')
|
||||||
const userAgent = getHeader(event, 'user-agent')
|
const userAgent = getHeader(event, 'user-agent')
|
||||||
|
const nodeEnv = process.env.NODE_ENV || 'development'
|
||||||
|
|
||||||
|
// Debug-Ausgaben immer ausgeben (nicht nur in dev)
|
||||||
console.log('[DEBUG] register-passkey-options request received', {
|
console.log('[DEBUG] register-passkey-options request received', {
|
||||||
origin: requestOrigin,
|
origin: requestOrigin,
|
||||||
userAgent: userAgent?.substring(0, 100),
|
userAgent: userAgent?.substring(0, 100),
|
||||||
method: getMethod(event),
|
method: getMethod(event),
|
||||||
timestamp: new Date().toISOString()
|
timestamp: new Date().toISOString(),
|
||||||
|
nodeEnv: nodeEnv,
|
||||||
|
pid: process.pid
|
||||||
})
|
})
|
||||||
|
|
||||||
const body = await readBody(event)
|
const body = await readBody(event)
|
||||||
|
|||||||
Reference in New Issue
Block a user