fix: add security headers and no-cache for index.html in nginx config

- X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy
- Prevent caching index.html so SPA updates are always picked up
- Add engines field (node >=18) and lint:fix script to package.json
This commit is contained in:
Nicolas Varrot
2026-02-13 03:27:29 +00:00
parent f27f386332
commit 979bc14ca8
3 changed files with 21 additions and 3 deletions

View File

@@ -4,16 +4,29 @@ server {
root /usr/share/nginx/html;
index index.html;
# Security headers
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
location / {
try_files $uri $uri/ /index.html;
}
# Cache static assets
# Cache static assets (hashed filenames — safe to cache forever)
location /assets/ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Don't cache index.html (SPA entry point must always be fresh)
location = /index.html {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
}
# Gzip
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript image/svg+xml;