server { listen 3800; # Changed to port 3800 to match external Nginx config server_name localhost; # Root directory for static files root /usr/share/nginx/html; index index.html; # Enable gzip compression gzip on; gzip_min_length 1000; gzip_proxied expired no-cache no-store private auth; gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; # Add CORS headers for static assets including images location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { expires 30d; add_header Cache-Control "public, no-transform"; 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, Authorization' always; try_files $uri =404; } # Forward all requests to index.html for SPA routing location / { try_files $uri $uri/ /index.html; # Add CORS headers for all responses add_header Access-Control-Allow-Origin * always; add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always; add_header Access-Control-Allow-Headers 'Origin, X-Requested-With, Content-Type, Accept, Authorization' always; } # Respond to preflighted CORS requests location /api/ { if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin * always; add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always; add_header Access-Control-Allow-Headers 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization' always; add_header Access-Control-Max-Age 1728000; add_header Content-Type 'text/plain charset=UTF-8'; add_header Content-Length 0; return 204; } try_files $uri $uri/ /index.html; } # Don't cache HTML location ~* \.html$ { expires -1; add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate"; } # Error handling error_page 404 /index.html; error_page 500 502 503 504 /index.html; }