diff --git a/image-recipe/configs/nginx-archipelago.conf b/image-recipe/configs/nginx-archipelago.conf index c908eb82..72e55eeb 100644 --- a/image-recipe/configs/nginx-archipelago.conf +++ b/image-recipe/configs/nginx-archipelago.conf @@ -125,6 +125,23 @@ server { # `always` the header applies only to 2xx/3xx; 404s are routed to a # named location that marks them no-store so the browser retries. location /assets/ { + try_files $uri @aiui_assets; + add_header Cache-Control "public, max-age=31536000, immutable"; + } + # AIUI's built index.html emits ABSOLUTE /assets/ paths, so they + # land here, in the MAIN UI's assets dir, where they do not exist — the + # real files are in aiui/assets/. The nearby /aiui-assets/ alias names this + # exact problem in its comment but only catches a path AIUI never requests, + # so it never fixed it. + # + # A fallback rather than copying the files up one level: a frontend deploy + # replaces web-ui wholesale (update.rs preserves the aiui/ directory itself, + # not copies made into assets/), so a copy is erased by the very next deploy + # while this survives. Hash collision with a real main-UI asset is not a + # concern — Vite hashes are content-derived, and a main asset that exists is + # served by try_files before this is ever consulted. + location @aiui_assets { + rewrite ^/assets/(.*)$ /aiui/assets/$1 break; try_files $uri =404; add_header Cache-Control "public, max-age=31536000, immutable"; error_page 404 = @asset_missing; @@ -985,6 +1002,23 @@ server { # HTTP block). No `always` on the immutable header: a transient 404 must # not be cached for a year — 404s go to @asset_missing (no-store) instead. location /assets/ { + try_files $uri @aiui_assets; + add_header Cache-Control "public, max-age=31536000, immutable"; + } + # AIUI's built index.html emits ABSOLUTE /assets/ paths, so they + # land here, in the MAIN UI's assets dir, where they do not exist — the + # real files are in aiui/assets/. The nearby /aiui-assets/ alias names this + # exact problem in its comment but only catches a path AIUI never requests, + # so it never fixed it. + # + # A fallback rather than copying the files up one level: a frontend deploy + # replaces web-ui wholesale (update.rs preserves the aiui/ directory itself, + # not copies made into assets/), so a copy is erased by the very next deploy + # while this survives. Hash collision with a real main-UI asset is not a + # concern — Vite hashes are content-derived, and a main asset that exists is + # served by try_files before this is ever consulted. + location @aiui_assets { + rewrite ^/assets/(.*)$ /aiui/assets/$1 break; try_files $uri =404; add_header Cache-Control "public, max-age=31536000, immutable"; error_page 404 = @asset_missing;