From 918e45f9da32544961954ad40904b030fd63a6b6 Mon Sep 17 00:00:00 2001 From: asepharyana Date: Thu, 2 Jul 2026 03:42:56 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20update=20nginx=20for=20Astro=20SSG=20?= =?UTF-8?q?=E2=80=94=20/=5Fastro/=20cache,=20remove=20SPA=20fallback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infra/docker/nginx/nginx-frontend.conf | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/infra/docker/nginx/nginx-frontend.conf b/infra/docker/nginx/nginx-frontend.conf index 6b1c57d..7ddaa56 100644 --- a/infra/docker/nginx/nginx-frontend.conf +++ b/infra/docker/nginx/nginx-frontend.conf @@ -1,4 +1,4 @@ -# Nginx config for serving Vite-built static frontend files +# Nginx config for serving Astro-built static frontend files server { listen 3000; server_name _; @@ -11,14 +11,15 @@ server { gzip_types text/plain text/css application/json application/javascript image/svg+xml; gzip_min_length 256; - # Cache static assets (JS/CSS hashed filenames) - location /assets/ { + # Cache Astro hashed assets (/_astro/) — immutable since hash changes + location /_astro/ { expires 1y; add_header Cache-Control "public, immutable"; } - # SPA fallback — all non-file routes serve index.html + # Astro SSG pages — each route is a real directory with index.html + # Fallback to 404 instead of index.html (no SPA catch-all) location / { - try_files $uri $uri/ /index.html; + try_files $uri $uri/ =404; } }