diff --git a/infra/traefik/dynamic/services.yml b/infra/traefik/dynamic/services.yml index 9382a21..e0a2b91 100644 --- a/infra/traefik/dynamic/services.yml +++ b/infra/traefik/dynamic/services.yml @@ -68,8 +68,10 @@ http: headers: customResponseHeaders: Cache-Control: "no-cache" - # lex. (the dossier app): every path serves the static page Gitea - # holds in custom/public, so Gitea's own pages never appear on lex. + # lex. catch-all. Paths that are not a dossier module, the policy + # API, or the focus pane become the static page. lex-assets is a + # higher-priority router and must not use this middleware: the rewrite + # would return index.html for app.js and the page would stay on Loading. lex-page: replacePathRegex: regex: "^/.*$" @@ -218,6 +220,29 @@ http: - git-sso - dossier-nocache - secure-headers + # Dossier modules on lex. Priority sits above the catch-all, which + # rewrites every path to index.html. Flat names only, same as lex_probe. + lex-assets: + rule: "Host(`lex.{{ $domain }}`) && PathRegexp(`^/assets/dossier/[a-z][a-z0-9-]*[.]js$`)" + priority: 1000 + service: git + entryPoints: + - web + middlewares: + - git-sso + - dossier-nocache + - secure-headers + lex-assets-tls: + rule: "Host(`lex.{{ $domain }}`) && PathRegexp(`^/assets/dossier/[a-z][a-z0-9-]*[.]js$`)" + priority: 1000 + service: git + entryPoints: + - websecure + tls: {} + middlewares: + - git-sso + - dossier-nocache + - secure-headers # Pane paths, higher priority than the host routers. /ui/focus covers # focus.js and focus_anchor.mjs; /ui/vendor is the pdf.js worker. lex-focus: diff --git a/tests/dev/test_lex_probe.py b/tests/dev/test_lex_probe.py index bf963dd..5c40073 100644 --- a/tests/dev/test_lex_probe.py +++ b/tests/dev/test_lex_probe.py @@ -47,6 +47,26 @@ def test_route_target_mirrors_traefik() -> None: assert rt(path) == ("page", ""), path +def test_services_yml_serves_lex_modules_without_the_page_rewrite() -> None: + """The catch-all rewrites every lex path to index.html. Module requests + have to hit a higher-priority router that does not use that middleware, + or the browser receives HTML for app.js and the page stays on Loading.""" + src = (ROOT / "infra/traefik/dynamic/services.yml").read_text() + rule = "PathRegexp(`^/assets/dossier/[a-z][a-z0-9-]*[.]js$`)" + blocks = re.findall( + r"\n (lex-assets(?:-tls)?):\n(.*?)(?=\n [a-z0-9-]+:\n)", + src, + re.S, + ) + assert [name for name, _ in blocks] == ["lex-assets", "lex-assets-tls"] + for name, body in blocks: + assert rule in body, name + assert "priority: 1000" in body, name + assert "service: git" in body, name + assert "lex-page" not in body, name + assert "git-sso" in body and "dossier-nocache" in body, name + + def test_probe_imports_without_playwright() -> None: src = (ROOT / "dev/scripts/lex_probe.py").read_text(encoding="utf-8") top = src.split("\ndef main(", 1)[0]