diff --git a/Cargo.lock b/Cargo.lock index 90c41b2..b39e22e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4680,6 +4680,8 @@ dependencies = [ "odyssey-wallet", "reth-tracing", "tokio", + "tower 0.4.13", + "tower-http", "tracing", "url", ] diff --git a/Cargo.toml b/Cargo.toml index f36e790..22b8331 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -221,6 +221,8 @@ metrics = "0.23.0" metrics-derive = "0.1.0" # rpc +tower = "0.4" +tower-http = { version = "0.6", features = ["cors"] } jsonrpsee = "0.24" # misc diff --git a/bin/odyssey/Cargo.toml b/bin/odyssey/Cargo.toml index 89a182d..7c694e4 100644 --- a/bin/odyssey/Cargo.toml +++ b/bin/odyssey/Cargo.toml @@ -17,6 +17,7 @@ alloy-network.workspace = true alloy-primitives.workspace = true alloy-provider.workspace = true alloy-rpc-client.workspace = true +clap = { workspace = true, features = ["derive"] } odyssey-node.workspace = true odyssey-wallet.workspace = true odyssey-walltime.workspace = true @@ -27,7 +28,6 @@ reth-node-builder.workspace = true reth-optimism-node = { workspace = true, features = ["js-tracer"] } reth-optimism-cli.workspace = true reth-provider.workspace = true -clap = { workspace = true, features = ["derive"] } [features] default = ["jemalloc"] diff --git a/bin/relay/Cargo.toml b/bin/relay/Cargo.toml index 42bdbc9..7fba499 100644 --- a/bin/relay/Cargo.toml +++ b/bin/relay/Cargo.toml @@ -23,6 +23,8 @@ reth-tracing.workspace = true clap = { workspace = true, features = ["derive", "env"] } url.workspace = true tokio = { workspace = true, features = ["rt", "macros"] } +tower.workspace = true +tower-http.workspace = true [features] default = [] diff --git a/bin/relay/src/main.rs b/bin/relay/src/main.rs index 059d1d3..1e5fff2 100644 --- a/bin/relay/src/main.rs +++ b/bin/relay/src/main.rs @@ -11,6 +11,8 @@ use jsonrpsee::server::Server; use odyssey_wallet::{AlloyUpstream, OdysseyWallet, OdysseyWalletApiServer}; use reth_tracing::Tracer; use std::net::{IpAddr, Ipv4Addr}; +use tower::ServiceBuilder; +use tower_http::cors::CorsLayer; use tracing::info; use url::Url; @@ -52,7 +54,11 @@ impl Args { let rpc = OdysseyWallet::new(AlloyUpstream::new(provider), chain_id).into_rpc(); // start server - let server = Server::builder().http_only().build((self.address, self.port)).await?; + let server = Server::builder() + .http_only() + .set_http_middleware(ServiceBuilder::new().layer(CorsLayer::permissive())) + .build((self.address, self.port)) + .await?; info!(addr = ?server.local_addr().unwrap(), "Started relay service"); let handle = server.start(rpc);