### fix: verbessere CORS-Handling im Caddy-Proxy
All checks were successful
Build and Publish Docker Images / build-and-push (., backend/services/mail/Dockerfile, mail-service, mail-service) (push) Successful in 5m39s
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Successful in 3m53s

- **Caddyfile:** OPTIONS-Handling optimiert: Hinzufügen spezifischer Header (`X-Requested-With`), Entfernen von `*` und leere Response (`respond "" 204`) eingeführt.
- **UI:** Aktualisierung des Versionsmarkers auf `v2026-04-23.24 - CADDY CORS FINAL BOSS`.
- **Docs:** Erweiterung der Analyse um Lösung und Status für Version 24.
This commit is contained in:
Stefan Mogeritsch 2026-04-23 14:02:00 +02:00
parent af0ece8ded
commit 02a778751a
3 changed files with 14 additions and 4 deletions

View File

@ -24,18 +24,20 @@
header { header {
Access-Control-Allow-Origin "https://app.mo-code.at" Access-Control-Allow-Origin "https://app.mo-code.at"
Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
Access-Control-Allow-Headers "Content-Type, Authorization, *" Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With"
Access-Control-Allow-Credentials "true" Access-Control-Allow-Credentials "true"
Access-Control-Max-Age "3600" Access-Control-Max-Age "3600"
X-Caddy-CORS "preflight"
} }
respond 204 respond "" 204
} }
header { header {
Access-Control-Allow-Origin "https://app.mo-code.at" Access-Control-Allow-Origin "https://app.mo-code.at"
Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
Access-Control-Allow-Headers "Content-Type, Authorization, *" Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With"
Access-Control-Allow-Credentials "true" Access-Control-Allow-Credentials "true"
X-Caddy-CORS "forward"
defer defer
} }

View File

@ -92,3 +92,11 @@ Die "Hallo Du!" Test-UI wurde durch produktive, fachlich korrekte Formulare erse
- **Problem**: CORS Preflight (OPTIONS) wurde blockiert, vermutlich weil 'defer' Header verzögerte oder 'Access-Control-Allow-Headers' nicht spezifisch genug war. - **Problem**: CORS Preflight (OPTIONS) wurde blockiert, vermutlich weil 'defer' Header verzögerte oder 'Access-Control-Allow-Headers' nicht spezifisch genug war.
- **Lösung**: Caddyfile umgebaut. OPTIONS-Requests werden nun in einem eigenen Handle mit expliziten Headern (inkl. Content-Type) beantwortet, ohne 'defer'. - **Lösung**: Caddyfile umgebaut. OPTIONS-Requests werden nun in einem eigenen Handle mit expliziten Headern (inkl. Content-Type) beantwortet, ohne 'defer'.
- **Status**: Versionsmarker auf v2026-04-23.23 aktualisiert. - **Status**: Versionsmarker auf v2026-04-23.23 aktualisiert.
### v2026-04-23.24 - CADDY CORS FINAL BOSS
- **Problem**: CORS Preflight (OPTIONS) weiterhin blockiert (v23). Die Fehlermeldung deutete darauf hin, dass die Header immer noch nicht zuverlässig beim Browser ankommen.
- **Lösung**:
- `Caddyfile` radikal gehärtet: `OPTIONS` Requests werden nun mit `X-Caddy-CORS: preflight` markiert und erhalten eine leere Response (`respond "" 204`).
- Hinzufügen von `X-Requested-With` zu den erlaubten Headern (oft von KMP/Ktor-Clients verwendet).
- Entfernung von `*` aus den Allowed-Headers, um maximale Kompatibilität mit restriktiven Browsern sicherzustellen.
- **Status**: Versionsmarker auf v2026-04-23.24 aktualisiert.

View File

@ -124,7 +124,7 @@ fun MainAppContent() {
// Dezentraler Versions-Marker in der unteren rechten Ecke // Dezentraler Versions-Marker in der unteren rechten Ecke
Box(modifier = Modifier.fillMaxSize().padding(8.dp), contentAlignment = Alignment.BottomEnd) { Box(modifier = Modifier.fillMaxSize().padding(8.dp), contentAlignment = Alignment.BottomEnd) {
Text( Text(
text = "v2026-04-23.23 - CADDY CORS OPTIONS FIX", text = "v2026-04-23.24 - CADDY CORS FINAL BOSS",
style = MaterialTheme.typography.labelSmall, style = MaterialTheme.typography.labelSmall,
color = Color.LightGray.copy(alpha = 0.5f) color = Color.LightGray.copy(alpha = 0.5f)
) )