# Reverse Proxy Configuration for demobackend.aibitsoft.cloud
# This configuration only affects this directory and does not impact other projects

# If 503 is ever returned from this dir, send CORS so the browser can read the error
ErrorDocument 503 /error-503.php

RewriteEngine On

# CORS preflight: send OPTIONS to a PHP script that returns 204 + CORS headers (no mod_headers needed)
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^ options-handler.php [L]

# Allow ACME/AutoSSL HTTP DCV - serve .well-known/acme-challenge directly (must be before proxy rule)
# Prevents 404 for Let's Encrypt validation; no impact on other projects
# Match per-dir path (no leading slash; dot may be stripped on some servers)
RewriteRule ^\.?well-known/ - [L]

# Route all requests to index.php for proxying
# This ensures all requests go through the PHP proxy to Node.js backend
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]

