diff --git a/nix/modules/hive-gateway.nix b/nix/modules/hive-gateway.nix index bd461f4f..74af4d26 100644 --- a/nix/modules/hive-gateway.nix +++ b/nix/modules/hive-gateway.nix @@ -164,7 +164,29 @@ in "/matrix/" = { alias = "${matrixCfg.gui.package}/"; extraConfig = '' - try_files $uri $uri/ /matrix/index.html; + try_files $uri $uri/ @matrix_spa_fallback; + ''; + }; + # SPA fallback (iris/#643). The naive + # `try_files $uri $uri/ /matrix/index.html;` shape + # silently masked missing static assets — flutter's + # bootstrap requesting e.g. `/matrix/native_executor.js` + # got `index.html` (Content-Type: text/html, status + # 200) when the file was absent from the dist, so + # the JS runtime never loaded and `/matrix/` rendered + # blank without any visible error. + # + # Asset-shaped URIs (anything with a `.` segment) + # get an explicit 404 so the SPA + browser see the + # missing-asset error cleanly. Only route-shaped URIs + # (no extension) fall through to index.html for SPA + # client-side routing. + "@matrix_spa_fallback" = { + extraConfig = '' + if ($uri ~ "\.[A-Za-z0-9]+$") { + return 404; + } + rewrite ^ /matrix/index.html last; ''; }; }