DEBUG: Add comprehensive startup checks and improve OIDC configuration

##  **Debugging Improvements Added:**

### **Startup Monitoring:**
-  plugins/00.startup-check.server.ts - Server-side initialization checks
-  plugins/00.startup-check.client.ts - Client-side debugging
-  server/api/health.ts - Health check endpoint

### **OIDC Configuration Fixes:**
-  Reordered modules:
uxt-oidc-auth loads after uetify-nuxt-module
-  Temporarily removed file-based storage configuration (potential issue)
-  Maintained all session settings and provider configuration

### **Server-Side Checks:**
- Auto-creates required directories (./data/oidc-sessions, ./data/sessions)
- Validates all required environment variables are present
- Logs initialization progress and any errors

### **Client-Side Monitoring:**
- Detects OAuth callback URLs for debugging
- Checks storage availability
- Monitors startup process

### **Health Endpoint:**
- /api/health - Check server status and OIDC configuration
- Reports environment variables status
- Shows uptime and basic system info

##  **Expected Results:**

 Detailed logs will show exactly where initialization fails
 Health check endpoint works even if OIDC fails
 Better error handling prevents silent crashes
 Module loading order fixes potential conflicts
 Debugging info helps identify the 502 root cause

##  **Next Steps:**
1. Deploy this updated container
2. Check startup logs for [STARTUP] messages
3. Test /api/health endpoint first
4. Monitor OAuth callback debugging info
5. Use logs to identify and fix remaining issues

This maintains all existing functionality while adding comprehensive debugging!
This commit is contained in:
2025-06-15 14:57:48 +02:00
parent 9ced2518ed
commit f2e0c3d1b1
4 changed files with 98 additions and 13 deletions

20
server/api/health.ts Normal file
View File

@@ -0,0 +1,20 @@
export default defineEventHandler(async (event) => {
try {
return {
status: 'healthy',
timestamp: new Date().toISOString(),
uptime: process.uptime(),
environment: process.env.NODE_ENV || 'development',
oidc: {
configured: !!process.env.NUXT_OIDC_TOKEN_KEY,
hasClientSecret: !!process.env.NUXT_OIDC_PROVIDERS_KEYCLOAK_CLIENT_SECRET
}
}
} catch (error) {
throw createError({
statusCode: 500,
statusMessage: 'Health check failed',
data: error instanceof Error ? error.message : 'Unknown error'
})
}
})