server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # (Optional) redirect bare root to /watch-party/ # Helps avoid loading "/" by mistake (your log shows that happened once) location = / { return 302 /watch-party/; } # Redirect no-trailing-slash to trailing slash location = /watch-party { return 302 /watch-party/; } # Serve the SPA under /watch-party/ using alias # /watch-party/... -> /usr/share/nginx/html/... location /watch-party/ { alias /usr/share/nginx/html/; try_files $uri $uri/ /index.html; } # Proxy API unchanged (your React app should request /api/current) location /api/ { 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_set_header Connection ""; proxy_pass ${BACKEND_ORIGIN}/; } }