<VirtualHost *:443>
    ServerName laloee-cours.fr

    DocumentRoot /var/www/laloee-cours.fr

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/laloee-cours.fr/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/laloee-cours.fr/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf

    # Proxy React dev server
    ProxyPreserveHost On
    ProxyPass /social-media-generator/app/ http://localhost:3000/
    ProxyPassReverse /social-media-generator/app/ http://localhost:3000/

    # WebSocket support
    ProxyPass /social-media-generator/app/sockjs-node/ ws://localhost:3000/sockjs-node/
    ProxyPassReverse /social-media-generator/app/sockjs-node/ ws://localhost:3000/sockjs-node/

    # Allow encoded slashes for React routing
    AllowEncodedSlashes NoDecode

    # Alias for PHP backend
    Alias /social-media-generator /var/www/laloee-cours.fr/social-media-generator

    <Directory "/var/www/laloee-cours.fr/social-media-generator">
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/laloee_php_error.log
    CustomLog ${APACHE_LOG_DIR}/laloee_php_access.log combined
</VirtualHost>
