server { listen 7860; server_name _; root /app/frontend/build; index index.html; # Allow HuggingFace to embed this app in an iframe add_header X-Frame-Options "" always; add_header Content-Security-Policy "frame-ancestors 'self' https://huggingface.co https://*.hf.space;" always; add_header Cross-Origin-Opener-Policy "unsafe-none" always; add_header Cross-Origin-Embedder-Policy "unsafe-none" always; # Gzip gzip on; gzip_types text/plain text/css application/json application/javascript text/javascript; # Proxy all /api/* requests to the Node.js backend location /api/ { proxy_pass http://127.0.0.1:5000; proxy_http_version 1.1; proxy_set_header Host $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_read_timeout 60s; } # Health check pass-through location /health { proxy_pass http://127.0.0.1:5000/health; } # React SPA — every unknown route serves index.html location / { try_files $uri $uri/ /index.html; } # Cache static assets aggressively location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable"; try_files $uri =404; } }