Contoh Konfigurasi Aman vs Longgar
Aman — origin spesifik (disarankan bila harus akses browser)
# elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "https://panel.contoh.com"
http.cors.allow-credentials: true
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: X-Requested-With, Content-Type, Content-Length, Authorization
Untuk beberapa origin, pakai regex: http.cors.allow-origin: "/https?://(panel|admin)\.contoh\.com/" (apit dengan garis miring).
Longgar — wildcard (hanya untuk dev lokal)
# JANGAN dipakai di produksi terbuka
http.cors.enabled: true
http.cors.allow-origin: "*"
Kombinasi allow-origin: "*" dengan allow-credentials: true ditolak browser dan berbahaya. Jika cluster Anda tanpa autentikasi dan terekspos, wildcard memungkinkan situs mana pun memanggil cluster lewat browser korban. Hindari di produksi.