# ─────────────────────────────────────────────────────────────────────────────
#  Apache VirtualHost — Headless W CRM
#  Server: w.bostonwebgroup.com  |  cPanel user: h34dl355
#
#  HOW TO USE:
#  Option A (easiest) — use deploy/htaccess.txt instead (no httpd.conf access needed)
#  Option B — paste this VirtualHost block into httpd.conf or conf.d if you have root
# ─────────────────────────────────────────────────────────────────────────────

<VirtualHost *:80>
    ServerName w.bostonwebgroup.com

    DocumentRoot /home/h34dl355/headless-w/artifacts/proposa/dist/public

    <Directory /home/h34dl355/headless-w/artifacts/proposa/dist/public>
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass        /api  http://127.0.0.1:3099/api
    ProxyPassReverse /api  http://127.0.0.1:3099/api

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteCond %{REQUEST_URI} !^/api
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^ /index.html [L]
    </IfModule>

    ErrorLog  /home/h34dl355/logs/headless-w-error.log
    CustomLog /home/h34dl355/logs/headless-w-access.log combined
</VirtualHost>

# HTTPS — run AutoSSL in cPanel first, then uncomment:
# <VirtualHost *:443>
#     ServerName w.bostonwebgroup.com
#     SSLEngine on
#     SSLCertificateFile    /etc/letsencrypt/live/w.bostonwebgroup.com/fullchain.pem
#     SSLCertificateKeyFile /etc/letsencrypt/live/w.bostonwebgroup.com/privkey.pem
#     DocumentRoot /home/h34dl355/headless-w/artifacts/proposa/dist/public
#     ProxyPass        /api  http://127.0.0.1:3099/api
#     ProxyPassReverse /api  http://127.0.0.1:3099/api
#     <IfModule mod_rewrite.c>
#         RewriteEngine On
#         RewriteBase /
#         RewriteCond %{REQUEST_URI} !^/api
#         RewriteCond %{REQUEST_FILENAME} !-f
#         RewriteCond %{REQUEST_FILENAME} !-d
#         RewriteRule ^ /index.html [L]
#     </IfModule>
# </VirtualHost>
