diff --git a/deploy-production.sh b/deploy-production.sh index 2e782da..e617d90 100755 --- a/deploy-production.sh +++ b/deploy-production.sh @@ -137,28 +137,106 @@ npm install # 4. Remove old build (but keep data!) echo "" -echo "4. Removing old build output..." -rm -rf .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 + # 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 echo "" 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 - echo "ERROR: Build fehlgeschlagen - .output/public/_nuxt Verzeichnis fehlt!" - echo "Bitte prüfen Sie die Build-Ausgabe auf Fehler." - exit 1 + echo "ERROR: .output/public/_nuxt Verzeichnis fehlt!" + BUILD_FAILED=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 -# Prüfe, ob wichtige Dateien vorhanden sind +# Check 2: Server index.mjs 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 fi -echo " Build erfolgreich - .output/public/_nuxt vorhanden" +echo " ✓ Build erfolgreich verifiziert" # 6. Restore Production Data (überschreibe Repo-Defaults mit Backup) echo "" diff --git a/pages/registrieren.vue b/pages/registrieren.vue index d2d066f..013132d 100644 --- a/pages/registrieren.vue +++ b/pages/registrieren.vue @@ -183,7 +183,7 @@
Challenge: {{ debugChallenge.substring(0, 40) }}...
RP-ID: {{ debugRpId }}
-
Origin: {{ window.location.origin }}
+
Origin: {{ typeof window !== 'undefined' ? window.location.origin : 'N/A (SSR)' }}
Hinweis: Der QR-Code wird vom Browser generiert. Prüfe in der Browser-Konsole (F12) für vollständige Debug-Ausgaben. @@ -513,12 +513,33 @@ const handleRegisterWithPasskey = async () => { const timeoutWarning = setTimeout(() => { 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] 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) }, 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)') - 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) diff --git a/server/api/auth/register-passkey-options.post.js b/server/api/auth/register-passkey-options.post.js index 117ecd1..f079183 100644 --- a/server/api/auth/register-passkey-options.post.js +++ b/server/api/auth/register-passkey-options.post.js @@ -13,12 +13,16 @@ export default defineEventHandler(async (event) => { const requestStart = Date.now() const requestOrigin = getHeader(event, 'origin') 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', { origin: requestOrigin, userAgent: userAgent?.substring(0, 100), method: getMethod(event), - timestamp: new Date().toISOString() + timestamp: new Date().toISOString(), + nodeEnv: nodeEnv, + pid: process.pid }) const body = await readBody(event)