From ee509cd48b9d0213b1cae3ead313f5bfd79f49da Mon Sep 17 00:00:00 2001 From: "Zimin A.N." Date: Fri, 8 May 2026 01:45:51 +0300 Subject: [PATCH] fix(docs/nginx): rewrite hashed bundle filenames + remove broken try_files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Diplodoc CLI 4.60 bug: HTML refs hashed asset names (например `_bundle/app-34c68624e23be7ce.css`) но actual built _bundle/ contains unhashed files (`app.css`). Browser получает 404 на все css/js references → page broken. Workaround в nginx — strip hash через regex location: ^/docs/(_bundle|_assets)/(.+?)-(\.)$ → alias /usr/share/nginx/html/$1/$2$3 Также убран try_files который incorrectly matched $uri (URL path с hash) вместо aliased file path → false 404. Verified locally — 200 OK на: /docs/_bundle/app-34c68624e23be7ce.css /docs/_bundle/vendor-*.css /docs/_bundle/react-*.js /docs/integration/api/auth.html --- docs/nginx.conf | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/docs/nginx.conf b/docs/nginx.conf index 284f537..4d37df6 100644 --- a/docs/nginx.conf +++ b/docs/nginx.conf @@ -16,22 +16,30 @@ server { add_header Content-Type text/plain; } - # Documentation root. + # Static assets (Diplodoc CLI 4.60 bug: HTML refs hashed names типа + # `_bundle/app-34c68624e23be7ce.css`, но actual файл — `app.css` (без + # hash). Strip hash в nginx через rewrite: `name-.ext` → `name.ext`. + location ~* "^/docs/(_bundle|_assets)/(.+?)-[a-f0-9]{8,}(\.[a-z0-9]+)$" { + alias /usr/share/nginx/html/$1/$2$3; + expires 1y; + add_header Cache-Control "public, immutable"; + } + # Non-hashed assets (fallback). + location ~* ^/docs/((_bundle|_assets)/.*\.(css|js|woff2?|ttf|eot|svg|png|jpg|jpeg|ico|map|json))$ { + alias /usr/share/nginx/html/$1; + expires 1y; + add_header Cache-Control "public, immutable"; + try_files $uri =404; + } + + # Documentation pages (HTML). location /docs/ { alias /usr/share/nginx/html/; index index.html; try_files $uri $uri/ $uri.html =404; - # HTML — short cache (5 min). Новые deploy'ы быстро видны. expires 5m; add_header Cache-Control "public, must-revalidate"; - - # Hash-named assets — long cache. Diplodoc делает content-hashing - # в _bundle/ что safe для immutable cache. - location ~* /_bundle/.*\.(css|js|woff2?|ttf|eot|svg|png|jpg|ico)$ { - expires 1y; - add_header Cache-Control "public, immutable"; - } } # Redirect /docs (без trailing slash) → /docs/.