meldestelle/config/docker/caddy/web-app/Caddyfile
StefanMoCoAt 71aea3f41d
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
### fix: verbessere CORS-Handling im Caddy-Proxy
- **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.
2026-04-23 13:02:52 +02:00

81 lines
2.0 KiB
Caddyfile

{
auto_https off
metrics
}
:80 {
root * /usr/share/caddy
log {
output stdout
format json
}
header {
Cross-Origin-Embedder-Policy "require-corp"
Cross-Origin-Opener-Policy "same-origin"
}
encode gzip zstd
# 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
}
handle /health {
respond "healthy" 200
}
# Korrekte MIME für .wasm sicherstellen (Caddy erkennt es i. d. R. automatisch; hier explizit)
@wasm {
path *.wasm
}
header @wasm Content-Type "application/wasm"
# Caching-Strategie: Immutable Assets (hash-Dateien)
# WICHTIG: .wasm und .js werden hier gecached. Falls die Dateinamen gleich bleiben,
# wird der Browser sie NICHT neu laden.
@immutable {
path *.png *.svg *.ico *.woff2 *.map
}
header @immutable Cache-Control "public, max-age=31536000, immutable"
# Wasm und JS Dateien: Kein Cache während der aktiven Entwicklungsphase (Plan-B)
# um "Alte Seite" Probleme zu vermeiden.
@wasm_js {
path *.wasm *.js
}
header @wasm_js Cache-Control "no-store, no-cache, must-revalidate"
# Keine Cache-Header für SPA-Einstieg und Laufzeitkonfig
@nocache {
path /index.html /config.json
}
header @nocache Cache-Control "no-store"
# Static file serving mit SPA-Fallback
handle {
try_files {path} /index.html
file_server
}
}