# ==========================================
# Contractors411 - .htaccess for Namecheap
# ==========================================
# Proxies all requests to the Node.js app.
# After setting up via cPanel Node.js Selector,
# replace the port below with the assigned port.

Options -Indexes

RewriteEngine On

# Don't rewrite existing files (css, js, images, uploads)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Proxy to Node.js app
# UPDATE THIS PORT after setting up in cPanel Node.js Selector
# 1. Go to cPanel → Setup Node.js App → Select this app
# 2. Copy the port number shown there (e.g., 8080)
# 3. Replace 3001 below with that port number
RewriteRule ^(.*)$ http://127.0.0.1:3001/$1 [P,L]

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

# Deny access to sensitive files
<FilesMatch "\.(env|json|lock|md)$">
  Order allow,deny
  Deny from all
</FilesMatch>

# Deny access to node_modules
RedirectMatch 403 /node_modules/.*$
