setBasePath('/'); $router->mount("/api", function() use($router) { require_once __DIR__ . '/api/index.php'; }); $router->set404('/api(/.*)?', function() { header('HTTP/1.1 404 Not Found'); header('Content-Type: application/json'); echo json_encode([ "message" => "Route not defined." ]); }); $router->get("/.*", function() { header('Content-Type: text/html; charset=UTF-8'); echo "frontend!"; }); $router->run();