<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  # CORS headers
  Header set Access-Control-Allow-Origin "*"
  Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
  Header set Access-Control-Allow-Headers "Content-Type, Authorization"

  # Direct execution of API requests in api directory
  RewriteRule ^api/(.*)$ api/$1 [L,QSA]

  # Allow direct access to physical files and directories
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^ - [L]

  # Fallback to index.html or root entry for client routing
  RewriteRule ^ index.html [L]
</IfModule>

# Security & Upload Limits for PHP
<IfModule mod_php7.c>
  php_value upload_max_filesize 64M
  php_value post_max_size 64M
  php_value memory_limit 256M
</IfModule>

<IfModule mod_php8.c>
  php_value upload_max_filesize 64M
  php_value post_max_size 64M
  php_value memory_limit 256M
</IfModule>
