Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

### Fixed

- [#6327](https://github.com/ChainSafe/forest/pull/6327) Fixed: Forest returns 404 for all invalid api paths.

## Forest v0.30.5 "Dulce de Leche"

Non-mandatory release supporting new API methods and addressing a critical panic issue.
Expand Down
12 changes: 11 additions & 1 deletion src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,17 @@ where
let filter_list = filter_list.clone();
move |req| {
let is_websocket = jsonrpsee::server::ws::is_upgrade_request(&req);
let path = ApiPaths::from_uri(req.uri()).unwrap_or(ApiPaths::V1);
let path = if let Ok(p) = ApiPaths::from_uri(req.uri()) {
p
} else {
return async move {
Ok(http::Response::builder()
.status(http::StatusCode::NOT_FOUND)
.body(Default::default())
.unwrap_or_else(|_| http::Response::new(Default::default())))
}
.boxed();
};
let methods = methods.get(&path).cloned().unwrap_or_default();
let PerConnection {
stop_handle,
Expand Down
4 changes: 1 addition & 3 deletions src/rpc/reflect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ impl ApiPaths {
}

pub fn from_uri(uri: &Uri) -> anyhow::Result<Self> {
Ok(Self::from_str(
uri.path().split("/").last().expect("infallible"),
)?)
Ok(Self::from_str(uri.path().trim_start_matches("/rpc/"))?)
}

pub fn path(&self) -> &'static str {
Expand Down
Loading