Estoy trabajando en una aplicación de una sola página, ahora atascado en el enrutamiento, he intentado diferentes formas pero mi código siempre devuelve 404. Necesito ayuda ahora
const route = (event) => { event = event || window.event; event.preventDefault(); window.history.pushState({}, "", event.target.href); handleLocation(); }; const routes = { 404: 404. php ', // http://localhost/spa/404.php', 'index': 'index.php', 'preparing': 'preparing.php', 'completed': 'completed.php', }; console.log("routes ", routes); const handleLocation = async() => { const path = window.location.href; const route = routes[path] || routes[404]; console.log("routes", route); const html = await fetch(route).then((data) => data.text()); document.getElementById("main-nav").innerHTML = html; }; window.onpopstate = handleLocation; window.route = route; handleLocation();