From e4937e3c7fb0e64d1f2882da05df00d4b3287334 Mon Sep 17 00:00:00 2001 From: teahubxyz Date: Wed, 14 Oct 2026 21:39:17 +0000 Subject: [PATCH] pages: apex redirects // only for venture pages (dir has index.html); asset folders and .well-known stay on the apex Fixes the shot of a venture whose subdomain is not ours (aicharts.yolopreneur.lol is a Worker) and the NIP-05 path at the apex. Also: HEAD flag no longer shadowed by the path segment (that bug emptied every GET body). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CYHXFvWMCs1GUmRmpySqQ6 --- pages/server.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pages/server.py b/pages/server.py index e571f11..dd170b4 100644 --- a/pages/server.py +++ b/pages/server.py @@ -126,9 +126,10 @@ class Handler(http.server.BaseHTTPRequestHandler): root = site_root(repo).resolve() rel = unquote(path).lstrip("/") # on a wildcard zone's apex, //... lives at .zone: send people there - head = rel.split("/", 1)[0] - if not sub and self.host() in WILDCARDS and head and (root / head).is_dir() and ".." not in rel: - self.send_response(301); self.send_header("location", f"https://{head}.{self.host()}/" + rel[len(head):].lstrip("/")); self.end_headers() + first = rel.split("/", 1)[0] + # only folders that are a venture page (have an index.html); assets folders, .well-known etc. stay on the apex + if not sub and self.host() in WILDCARDS and first and (root / first / "index.html").is_file() and ".." not in rel: + self.send_response(301); self.send_header("location", f"https://{first}.{self.host()}/" + rel[len(first):].lstrip("/")); self.end_headers() return if sub: root = (root / sub).resolve()