# .htaccess — Proxy cPanel domain to Node.js Funding API (port 3000)
# Place this file in the public_html directory of your cPanel account
# Requires mod_proxy, mod_proxy_http, and mod_rewrite to be enabled in Apache

# Enable rewrite engine
RewriteEngine On

# Proxy all requests to the Node.js application running on port 3000
# Change the port number if your app runs on a different port
RewriteRule ^$ http://127.0.0.1:3000/ [P,L]
RewriteRule ^(.*)$ http://127.0.0.1:3000/$1 [P,L]

# Pass through important headers
ProxyPreserveHost On
ProxyRequests Off

# Set proxy headers so the Node.js app sees the original client IP and host
RequestHeader set X-Forwarded-Host "%{HTTP_HOST}s"
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Real-IP "%{REMOTE_ADDR}s"

# WebSocket support (if needed in the future)
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://127.0.0.1:3000/$1" [P,L]

# Timeouts for long-running requests
ProxyTimeout 180
ProxyReceiveTimeout 180
ProxySendTimeout 180

# Security headers
Header set X-Content-Type-Options "nosniff"
Header set X-Frame-Options "SAMEORIGIN"
Header set X-XSS-Protection "1; mode=block"
Header set Referrer-Policy "strict-origin-when-cross-origin"

# Do not allow direct access to .htaccess
<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>
