diff --git a/starpilot/system/the_galaxy/assets/js/utils.js b/starpilot/system/the_galaxy/assets/js/utils.js index b00d24aac..37d86cb96 100644 --- a/starpilot/system/the_galaxy/assets/js/utils.js +++ b/starpilot/system/the_galaxy/assets/js/utils.js @@ -89,11 +89,5 @@ export function isGalaxyTunnel() { } export function galaxyPath(path) { - const suffix = path.startsWith("/") ? path : `/${path}` - if (!isGalaxyTunnel()) return suffix - - const firstPathSegment = window.location.pathname.split("/").filter(Boolean)[0] || "" - const slug = /^[A-Za-z0-9]{16}$/.test(firstPathSegment) ? `/${firstPathSegment}` : "" - if (!slug || suffix === slug || suffix.startsWith(`${slug}/`)) return suffix - return `${slug}${suffix}` + return path.startsWith("/") ? path : `/${path}` } diff --git a/starpilot/system/the_galaxy/the_galaxy.py b/starpilot/system/the_galaxy/the_galaxy.py index 92dcd90d7..6425160e6 100644 --- a/starpilot/system/the_galaxy/the_galaxy.py +++ b/starpilot/system/the_galaxy/the_galaxy.py @@ -5005,6 +5005,18 @@ def setup(app): @app.errorhandler(404) def not_found(_): + is_api = ( + request.path == "/api" + or "/api/" in request.path + or request.is_json + or (request.accept_mimetypes.accept_json and not request.accept_mimetypes.accept_html) + ) + if is_api or request.method not in ("GET", "HEAD"): + return jsonify({"error": "Not found"}), 404 + + if request.path.startswith(("/assets/", "/screen_recordings/", "/thumbnails/", "/video/")): + return "Not found", 404 + response = make_response(render_template("index.html")) response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, max-age=0" response.headers["Pragma"] = "no-cache"