Options -MultiViews
RewriteEngine On

# Let the cPanel Node app (Passenger) handle the admin API — never rewrite it to index.html
RewriteRule ^api/ - [L]

# SPA fallback: any request that is not a real file or directory goes to index.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.html [QSA,L]

# Cache-control: hashed assets get 1-year cache; index.html must revalidate every time
<IfModule mod_headers.c>
  # Vite hashes every JS/CSS/image filename — safe to cache forever
  <FilesMatch "\.(js|css|woff2?|ttf|eot|svg|png|jpg|jpeg|gif|ico|webp)$">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </FilesMatch>
  # index.html is the SPA entry point — must never be cached so new deploys take effect immediately
  <FilesMatch "^index\.html$">
    Header set Cache-Control "no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires "0"
  </FilesMatch>
</IfModule>
