server { listen 80; server_name localhost; # Set the root directory for serving files root /usr/share/nginx/html; # Specify the default file to serve index index.html; # Set default character set charset utf-8; # Configure routing for the Single Page Application (SPA) location / { # Try to serve the requested file directly, then as a directory, # and finally, fall back to index.html to let the client-side router handle it. try_files $uri $uri/ /index.html; } # Optional: Configure browser caching for static assets to improve performance. # This tells browsers they can cache these file types for one year. location ~* \.(?:css|js|jpg|jpeg|gif|png|ico|svg|woff|woff2)$ { expires 1y; add_header Cache-Control "public"; } }