# =========================================================================
# GHANA BLOCK FACTORY ERP - CPANEL / APACHE REVERSE PROXY & PASSENGER HTACCESS
# File: installer/.htaccess
# Place this file in your domain's /public_html directory
# =========================================================================

# 1. Enable Rewrite Engine
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Redirect HTTP to HTTPS (Optional - recommended for production)
    # RewriteCond %{HTTPS} off
    # RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # Proxy all incoming requests to Node.js server running on port 3000
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ http://127.0.0.1:3000/$1 [P,L]
</IfModule>

# 2. cPanel Phusion Passenger Startup Rules (if using cPanel Node.js App Selector)
<IfModule mod_passenger.c>
    PassengerAppRoot "/home/username/public_html"
    PassengerAppType node
    PassengerStartupFile dist/server.cjs
    PassengerNodejs "/usr/bin/node"
</IfModule>

# 3. Security Headers
<IfModule mod_headers.c>
    Header set X-Content-Type-Options "nosniff"
    Header set X-Frame-Options "SAMEORIGIN"
    Header set X-XSS-Protection "1; mode=block"
</IfModule>
