events {}

http {
    include       mime.types;
    default_type  application/octet-stream;

    # Configuration du serveur
    server {
        listen 80;

        # Redirige toutes les requêtes vers le front
        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
        }

        # Proxy pour l'API Node.js
       location /api {
            proxy_pass http://localhost:3000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            rewrite ^/api/(.*)$ /$1 break;
        }
    }
}
