apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-config
  labels:
    app: static-content
data:
  default.conf: |
    server {
        listen 80;
        server_name cdn.priet.us;

        root /usr/share/nginx/html;

        # Bloque para manejar solicitudes de archivos estáticos con CORS
        location ~* \.(css|js|woff|woff2|ttf|eot|svg)$ {
            add_header 'Access-Control-Allow-Origin' '*' always;
            add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
            add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept' always;

            # Manejar solicitudes OPTIONS (preflight)
            if ($request_method = 'OPTIONS') {
                add_header 'Access-Control-Allow-Origin' '*' always;
                add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
                add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept' always;
                add_header 'Content-Length' 0;
                add_header 'Content-Type' 'text/plain; charset=UTF-8';
                return 204;
            }

            try_files $uri $uri/ =404;
        }

        # Bloque para manejar otras solicitudes
        location / {
            try_files $uri $uri/ =404;
        }
    }

