From 5ffc81b6cabb0d684be4c4713ebc2275de3a7941 Mon Sep 17 00:00:00 2001 From: klemek Date: Sat, 18 Apr 2026 16:21:44 +0200 Subject: [PATCH] feat(handler): 404 on host not found --- README.md | 2 +- src/handlers.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 84ad8b7..253e270 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ curl -X DELETE \ - [x] docker compose example + .env - [ ] proper doc - [ ] unit tests -- [ ] 404 GET on host not found +- [x] 404 GET on host not found - [ ] 403 PUT on host already taken - [ ] X-Redirect - [ ] X-Proxy diff --git a/src/handlers.py b/src/handlers.py index 2052ee7..be6c53a 100644 --- a/src/handlers.py +++ b/src/handlers.py @@ -237,8 +237,10 @@ class RequestHandler(http.server.SimpleHTTPRequestHandler, _BaseHandler): def translate_path(self, path: str) -> str: if path.startswith(self.CERTBOT_CHALLENGE_PATH): return self.certbot_www + path - if (page := self.registry.get_from_host(self._get_host())) is not None: + if (page := self.registry.get_from_host(host := self._get_host())) is not None: path = f"/{page.path}" + path + elif host != self.default_host: + return "" elif ( path not in self.AUTHORIZED_PATHS and self.__get_subpath(path) is None ): # not a valid path