fix(infra): serve lex dossier modules without the page rewrite

The lex catch-all rewrote every path to index.html, so the browser received HTML for app.js and the page stayed on Loading. Module requests now use a higher-priority router that leaves the path alone.
This commit is contained in:
kert
2026-11-14 17:13:23 -05:00
parent c74dd0179b
commit f6c7b63a76
2 changed files with 47 additions and 2 deletions

View File

@@ -68,8 +68,10 @@ http:
headers:
customResponseHeaders:
Cache-Control: "no-cache"
# lex.<domain> (the dossier app): every path serves the static page Gitea
# holds in custom/public, so Gitea's own pages never appear on lex.
# lex.<domain> 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:

View File

@@ -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]