Ohne Cache-Header cachte der Browser die alte index.html -> neue Deploys (neue Asset-Hashes) kamen nie an, obwohl der Code laengst stimmte. Jetzt: index.html Cache-Control:no-cache (immer revalidieren), gehashte JS/CSS/Bilder immutable + 1 Jahr. Deploys sind damit sofort sichtbar. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
46 lines
1.8 KiB
Nginx Configuration File
46 lines
1.8 KiB
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name _;
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Foto-Uploads (Artikelbild, Logo/Favicon) brauchen mehr als die 1 MB, die
|
|
# nginx sonst zulaesst - sonst antwortet der Proxy mit 413, bevor das Backend
|
|
# den Upload ueberhaupt sieht.
|
|
client_max_body_size 12m;
|
|
|
|
# Universal Links: iOS holt diese Datei, um /i/<UID>-Links direkt in der App
|
|
# zu öffnen. Bewusst nur die Einzelstück-Pfade (/i/*); Lagerort-Links (/l/*)
|
|
# bleiben im Browser. Team-/Bundle-ID aus ios/project.yml.
|
|
location = /.well-known/apple-app-site-association {
|
|
default_type application/json;
|
|
return 200 '{"applinks":{"details":[{"appIDs":["PP34X97WS3.com.scarriffle.vorrania"],"components":[{"/":"/i/*"}]}]}}';
|
|
}
|
|
|
|
# Gehashte Assets (index-<hash>.js/.css, Bilder, Schriften): der Dateiname
|
|
# aendert sich bei jedem Build, wenn sich der Inhalt aendert -> unveraenderlich,
|
|
# deshalb aggressiv cachen.
|
|
location ~* \.(?:js|css|woff2?|ttf|eot|png|jpe?g|gif|svg|ico|webp)$ {
|
|
try_files $uri =404;
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
# SPA-Routing: unbekannte Pfade auf index.html mappen. index.html selbst darf
|
|
# NICHT gecacht werden - sonst laedt der Browser nach einem Deploy weiter die
|
|
# alte Seite mit den alten Asset-Verweisen, und Aenderungen kommen nie an.
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
add_header Cache-Control "no-cache";
|
|
}
|
|
|
|
# API an das Backend weiterleiten (Service-Name "backend" aus docker-compose)
|
|
location /api/ {
|
|
proxy_pass http://backend:8000/;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
}
|