Skip to content

Commit

Permalink
refactor(rpc-server): Add CORS to allow any origin
Browse files Browse the repository at this point in the history
  • Loading branch information
khorolets committed Dec 12, 2023
1 parent 197596e commit 49cea40
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rpc-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2021"

[dependencies]
actix-web = "4.2.1"
actix-cors = "0.6.5"
anyhow = "1.0.70"
assert-json-diff = { version = "2.0.2", optional = true }
aws-credential-types = "0.53.0"
Expand Down
10 changes: 10 additions & 0 deletions rpc-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,17 @@ async fn main() -> anyhow::Result<()> {

actix_web::HttpServer::new(move || {
let rpc = rpc.clone();

// Configure CORS
let cors = actix_cors::Cors::default()
.allow_any_origin()
.allowed_methods(vec!["GET", "POST", "OPTIONS"])
.allowed_headers(vec![http::header::ACCEPT])
.expose_any_header()
.max_age(3600);

actix_web::App::new()
.wrap(cors)
.wrap(tracing_actix_web::TracingLogger::default())
.service(
actix_web::web::service("/")
Expand Down

0 comments on commit 49cea40

Please sign in to comment.