use(BearerAuth::bearerAuth($token)); $api->get("/", function ($context) { return $context->json([ "message" => "Protected route accessed successfully", ]); }); $app->route("/api", $api); $app->run();