Files
harheimertc/server/api/auth/register-passkey-options.options.js
Torsten Schulz (local) 0deddeca51
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 49s
Enhance deployment script with PM2 process checks and error handling
Update deploy-production.sh to include checks for PM2 installation and process existence before restarting. Implement error messages for failed starts and restarts, improving robustness and user guidance during deployment. Additionally, add useful commands for managing the PM2 process post-deployment.
2026-01-08 11:24:38 +01:00

33 lines
1.1 KiB
JavaScript

import { getWebAuthnConfig } from '../../utils/webauthn-config.js'
export default defineEventHandler(async (event) => {
const requestOrigin = getHeader(event, 'origin')
const { origin: webauthnOrigin } = getWebAuthnConfig()
console.log('[DEBUG] OPTIONS preflight request received', {
origin: requestOrigin,
webauthnOrigin,
timestamp: new Date().toISOString()
})
// CORS-Header für Cross-Device Authentication
const allowedOrigin = requestOrigin || webauthnOrigin
if (allowedOrigin) {
setHeader(event, 'Access-Control-Allow-Origin', allowedOrigin)
setHeader(event, 'Access-Control-Allow-Credentials', 'true')
setHeader(event, 'Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
setHeader(event, 'Access-Control-Allow-Headers', 'Content-Type, Authorization, Origin, X-Requested-With')
setHeader(event, 'Access-Control-Max-Age', '86400') // 24 Stunden Cache für Preflight
console.log('[DEBUG] CORS headers set for OPTIONS', {
origin: allowedOrigin,
requestOrigin,
webauthnOrigin
})
}
// OPTIONS Preflight-Request: 204 No Content
setResponseStatus(event, 204)
return null
})