DirectoryIndex index.html
RewriteEngine On

# 1. Forward all backend API requests cleanly to port 8080
RewriteCond %{REQUEST_URI} ^/api [NC]
RewriteRule ^(.*)$ http://127.0.0.1:8080/$1 [P,L]

# 2. If it's a real physical file or folder on the server (like CSS, JS, or images), serve it directly
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# 3. Fallback catch-all: send all other web routes (/, /login, etc.) to your frontend React app
RewriteRule ^ index.html [L]
