# CONFIGURACIÓN NGINX PARA DESARROLLO CON HMR
# Reemplaza tu configuración actual de nginx con esta versión que soporta WebSockets

client_max_body_size 100M;

# Configuración específica para WebSocket HMR de Nuxt
location /_nuxt/ {
    proxy_pass http://192.168.87.135:3000;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    
    # Headers específicos para WebSocket HMR
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_cache_bypass $http_upgrade;
    
    # Timeouts para WebSocket
    proxy_connect_timeout 60s;
    proxy_send_timeout 60s;
    proxy_read_timeout 60s;
    
    # Headers específicos para assets de Nuxt
    proxy_set_header Accept-Encoding gzip;
}

# Configuración para DevTools
location /__nuxt_devtools__/ {
    proxy_pass http://192.168.87.135:3000;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    
    # WebSocket support para DevTools
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_cache_bypass $http_upgrade;
}

# Configuración para APIs
location /api/ {
    proxy_pass http://192.168.87.135:3000;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    
    # Timeouts más largos para archivos de música
    proxy_connect_timeout 60s;
    proxy_send_timeout 60s;
    proxy_read_timeout 60s;
    
    # Buffer settings para streaming de archivos grandes
    proxy_buffering off;
    proxy_request_buffering off;
    
    proxy_http_version 1.1;
}

# Configuración general para el resto
location / {
    proxy_pass http://192.168.87.135:3000;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    
    proxy_http_version 1.1;
    
    # Timeouts
    proxy_connect_timeout 30s;
    proxy_send_timeout 30s;
    proxy_read_timeout 30s;
}

# IMPORTANTE: NO agregar headers de seguridad en desarrollo
# Los headers X-Frame-Options, X-Content-Type-Options bloquean DevTools
# Solo usar en producción