v0.5.115: add History routing and SEO prerender for Climperor Web.
Path URLs, crawlable hero/mechanics pages, and sitemap make the static site indexable while keeping SPA hydration. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+22
-4
@@ -1115,11 +1115,29 @@ class Handler(BaseHTTPRequestHandler):
|
||||
return
|
||||
rel = path.lstrip("/")
|
||||
candidate = (WEB_DIR / rel).resolve()
|
||||
if not str(candidate).startswith(str(WEB_DIR.resolve())) or not candidate.is_file():
|
||||
self.send_error(404)
|
||||
web_root = WEB_DIR.resolve()
|
||||
if str(candidate).startswith(str(web_root)) and candidate.is_file():
|
||||
ctype = mimetypes.guess_type(str(candidate))[0] or "application/octet-stream"
|
||||
self._send(200, candidate.read_bytes(), ctype)
|
||||
return
|
||||
ctype = mimetypes.guess_type(str(candidate))[0] or "application/octet-stream"
|
||||
self._send(200, candidate.read_bytes(), ctype)
|
||||
# History SPA fallback: /heroes/axe → index.html (client router).
|
||||
spa_pages = {
|
||||
"heroes",
|
||||
"rankings",
|
||||
"matches",
|
||||
"streamers",
|
||||
"trends",
|
||||
"mechanics",
|
||||
"items",
|
||||
"patches",
|
||||
}
|
||||
first = path.strip("/").split("/", 1)[0] if path.strip("/") else ""
|
||||
if first in spa_pages:
|
||||
index = WEB_DIR / "index.html"
|
||||
if index.is_file():
|
||||
self._send(200, index.read_bytes(), "text/html; charset=utf-8")
|
||||
return
|
||||
self.send_error(404)
|
||||
|
||||
def do_POST(self) -> None: # noqa: N802
|
||||
path = urlparse(self.path).path
|
||||
|
||||
Reference in New Issue
Block a user