<IfModule mod_rewrite.c>
  RewriteEngine On

  # If you deploy the frontend under a subfolder, update RewriteBase accordingly.
  RewriteBase /

  # Let the backend handle API and uploads paths
  RewriteRule ^api/ - [L]
  RewriteRule ^uploads/ - [L]

  # Serve existing files/directories normally
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^ - [L]

  # SPA fallback
  RewriteRule ^ index.html [L]
</IfModule>
