# Kool & Saha API — Apache / cPanel
#
# Upload this together with the .php files. Files beginning with a dot are
# hidden in cPanel's File Manager: switch on "Show Hidden Files (dotfiles)"
# in its settings, or the API will look fine and fail on every signed-in call.

# 1. Apache hands PHP the Authorization header only when told to. Without this
#    every request arrives unauthenticated: sign-in appears to work, then the
#    profile never syncs and orders are refused with "لا يوجد حساب".
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP:Authorization} ^(.+)$
  RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
<IfModule mod_setenvif.c>
  SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
</IfModule>

# 2. The database password lives in config.php. Nothing should ever fetch it
#    over HTTP, and the shared-include files are not endpoints either.
<FilesMatch "^(config\.php|config\.example\.php|_.*\.php|schema\.sql|.*\.md)$">
  Require all denied
</FilesMatch>

# 3. No directory listing: without it, a missing index exposes the file names.
Options -Indexes

# 4. Answers are JSON and must not be cached by a proxy between phone and host.
<IfModule mod_headers.c>
  Header set Cache-Control "no-store"
  Header set X-Content-Type-Options "nosniff"
</IfModule>
