# BEGIN LED Configurator
# Managed by the LED Configurator installer. Edit outside this block; the block is replaced on update.
Options -Indexes
DirectoryIndex index.html

<IfModule mod_mime.c>
  AddType model/gltf-binary .glb
  AddType model/gltf+json .gltf
  AddType application/wasm .wasm
  AddType text/javascript .mjs
  AddType text/javascript .js
  AddType font/woff2 .woff2
  AddType video/mp4 .mp4
  AddType application/manifest+json .webmanifest
  AddType image/svg+xml .svg
  AddCharset utf-8 .html .css .js .mjs .svg
</IfModule>

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/json image/svg+xml application/wasm model/gltf-binary
</IfModule>

<IfModule mod_headers.c>
  Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; media-src 'self' blob:; font-src 'self' data:; connect-src 'self' data: blob:; worker-src 'self' blob:; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'"
  Header always set X-Content-Type-Options "nosniff"
  Header always set Referrer-Policy "no-referrer"
  Header always set Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=(), usb=(), interest-cohort=()"
  # files whose name contains a content hash never change: cache for a year
  <FilesMatch "-[A-Za-z0-9_-]{8}\.(js|css|woff2|wasm)$">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </FilesMatch>
  # everything else (index.html, 3D models, decoder) is checked with the server on every visit (cheap 304 when unchanged)
  <FilesMatch "\.(html|glb|gltf)$|^draco_(decoder|wasm_wrapper)\.(js|wasm)$">
    Header set Cache-Control "no-cache"
  </FilesMatch>
</IfModule>

# never serve dot-files or the installer's leftovers. install.php itself stays reachable on purpose: its
# "Delete the installer" button is a request to it (it protects itself: ownership proof file + CSRF token + install.lock)
<IfModule mod_authz_core.c>
  <FilesMatch "^(\.|install\.lock$|app\.zip$|led-install-)">
    Require all denied
  </FilesMatch>
</IfModule>
# {{HTTPS_REDIRECT}}
# END LED Configurator
