# =============================================================================
# Nginx http { } bloğunun İÇİNE bir kez ekleyin (ör. /etc/nginx/conf.d/ veya site üstü):
#   include /path/to/novazeka/livekit-selfhost/nginx-http-maps-livekit-cors.conf;
#
# WebSocket için (yoksa ekleyin):
#   map $http_upgrade $connection_upgrade {
#       default upgrade;
#       ''      close;
#   }
# =============================================================================

# LiveKit /rtc yanıtlarında Origin’i yansıt (localhost + site); eşleşmezse * (validate GET + preflight).
map $http_origin $livekit_cors_origin {
    "~^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$" $http_origin;
    "~^https?://\[::1\](:[0-9]+)?$" $http_origin;
    "~^https?://(192\.168\.[0-9]{1,3}\.[0-9]{1,3}|10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})(:[0-9]+)?$" $http_origin;
    "~^https?://([a-zA-Z0-9-]+\.)*novazeka\.com\.tr$" $http_origin;
    default "*";
}
