Options -Indexes
RewriteEngine On

# Keep one canonical HTTPS hostname.
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^www\.safelife\.website$ [NC]
RewriteRule ^ https://safelife.website%{REQUEST_URI} [R=301,L]

# Apache must have mod_proxy and mod_proxy_http enabled. The Node API itself is
# private on port 2084; browsers continue to use https://safelife.website.
RewriteRule ^api(?:/.*)?$ http://127.0.0.1:2084%{REQUEST_URI} [P,L,NE]
RewriteRule ^uploads(?:/.*)?$ http://127.0.0.1:2084%{REQUEST_URI} [P,L,NE]

# React Router fallback. Existing assets are served directly by Apache.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.html [L]

<IfModule mod_headers.c>
  Header always set X-Content-Type-Options "nosniff"
  Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>
