### 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 5m47s
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Successful in 3m54s

- **Caddyfile:** Verlagerung des CORS-Handlings in den Reverse Proxy, inkl. Unterstützung für Preflight-Anfragen und Header-Optimierungen.
- **UI:** Aktualisierung des Versionsmarkers auf `v2026-04-23.21 - CADDY CORS PROXY FIX`.
- **Docs:** Ergänzung der Problem- und Lösungshistorie für Version 21.
This commit is contained in:
Stefan Mogeritsch 2026-04-23 13:02:49 +02:00
parent 16c8674eff
commit 71aea3f41d
3 changed files with 28 additions and 1 deletions

View File

@ -19,6 +19,25 @@
# Reverse Proxy: Plan-B leitet nur /api/mail an den Mail-Service weiter (kein API-Gateway nötig)
handle /api/mail/* {
# CORS Handshake direkt im Proxy abfangen (Plan-B radikal)
@options method OPTIONS
header @options {
Access-Control-Allow-Origin "https://app.mo-code.at"
Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
Access-Control-Allow-Headers "*"
Access-Control-Allow-Credentials "true"
Access-Control-Max-Age "3600"
}
respond @options 204
# CORS Header auch für die eigentlichen Antworten (GET/POST) setzen
header {
Access-Control-Allow-Origin "https://app.mo-code.at"
Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
Access-Control-Allow-Headers "*"
Access-Control-Allow-Credentials "true"
}
reverse_proxy mail-service:8085
}

View File

@ -71,3 +71,11 @@ Die "Hallo Du!" Test-UI wurde durch produktive, fachlich korrekte Formulare erse
- CORS-Konfiguration in `GlobalSecurityConfig.kt` finalisiert: Whitelist für `https://*.mo-code.at` und `http://localhost:[*]` verfeinert.
- `allowedMethods` um `HEAD` erweitert und `exposedHeaders` hinzugefügt, um Browser-Warnungen zu eliminieren.
- **Status**: Versionsmarker auf v2026-04-23.20 aktualisiert.
### v2026-04-23.21 - CADDY CORS PROXY FIX
- **Problem**: Trotz umfangreicher Backend-Konfiguration (v20) meldete der Browser weiterhin fehlende CORS-Header bei Preflight-Anfragen (`No 'Access-Control-Allow-Origin' header`).
- **Lösung**:
- CORS-Handshaking wurde direkt in den Caddy-Reverse-Proxy (`Caddyfile` der Web-App) verlagert.
- OPTIONS-Requests werden nun sofort vom Proxy mit `204 No Content` und den korrekten CORS-Headern beantwortet.
- Damit wird sichergestellt, dass der Browser die Header erhält, noch bevor die Anfrage das Backend erreicht.
- **Status**: Versionsmarker auf v2026-04-23.21 aktualisiert.

View File

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