RewriteEngine On

# Ensure proper base path
RewriteBase /

# CORS headers will be handled by PHP middleware based on environment
# This ensures CORS is only enabled in development

# Handle preflight OPTIONS requests
<IfModule mod_headers.c>
    # Only handle OPTIONS requests to avoid interrupting normal requests
    RewriteCond %{REQUEST_METHOD} OPTIONS
    RewriteRule ^(.*)$ $1 [R=200,L]
</IfModule>

# Handle Front Controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
