diff --git a/Cargo.lock b/Cargo.lock index 04d4f5a6c8da1b588b28bbbd9dc2cf6c8106f80d..4d18b7725d34d9cfdb48a180ea50c44258638546 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,6 +31,17 @@ dependencies = [ "trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "actix-cors" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "actix-http" version = "0.2.11" @@ -667,6 +678,17 @@ dependencies = [ "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "derive_more" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "derive_more" version = "0.15.0" @@ -1048,6 +1070,7 @@ dependencies = [ name = "durs-gva" version = "0.1.0" dependencies = [ + "actix-cors 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "assert-json-diff 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3348,6 +3371,7 @@ dependencies = [ [metadata] "checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453" "checksum actix-connect 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9fade9bd4bb46bacde89f1e726c7a3dd230536092712f5d94d77ca57c087fca0" +"checksum actix-cors 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "66e5b071c68ac8ab182e7b7717167ef29ea93e166bc26391f678f19ac08ed129" "checksum actix-http 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "fcb50f77cd28240d344fd54afd205bae8760a3b0ad448b1716a2aa31e24db139" "checksum actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "23224bb527e204261d0291102cb9b52713084def67d94f7874923baefe04ccf7" "checksum actix-rt 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "88c9da1d06603d82ec2b6690fc5b80eb626cd2d6b573f3d9a71d5252e06d098e" @@ -3410,6 +3434,7 @@ dependencies = [ "checksum crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4" "checksum crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" "checksum ctor 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd8ce37ad4184ab2ce004c33bf6379185d3b1c95801cab51026bd271bf68eedc" +"checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" "checksum derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" diff --git a/lib/modules/gva/Cargo.toml b/lib/modules/gva/Cargo.toml index d094172e16e33600c29da691adbdf22ccd1ef70d..7c8c8c8bc21053c1821d578b0995d7deb7fbb3c5 100644 --- a/lib/modules/gva/Cargo.toml +++ b/lib/modules/gva/Cargo.toml @@ -11,6 +11,7 @@ path = "src/lib.rs" [dependencies] actix-web = "1.0.9" +actix-cors = "0.1.0" dubp-block-doc = { path = "../../dubp/block-doc"} #, version = "0.1.0" } dup-crypto = { path = "../../crypto" } durs-bc-db-reader = { path = "../../modules-lib/bc-db-reader", features = ["client-indexer"] } diff --git a/lib/modules/gva/src/webserver.rs b/lib/modules/gva/src/webserver.rs index da7ff2bf5e21b65a9c99fb06630c717ba1a54fca..7acdd273b17ff23cb3916176a4f88c1107e019af 100644 --- a/lib/modules/gva/src/webserver.rs +++ b/lib/modules/gva/src/webserver.rs @@ -18,7 +18,8 @@ use crate::context::GlobalContext; use crate::db::BcDbRo; use crate::graphql::graphql; use crate::schema::create_schema; -use actix_web::{middleware, web, App, HttpResponse, HttpServer}; +use actix_cors::Cors; +use actix_web::{http::header, middleware, web, App, HttpResponse, HttpServer}; #[cfg(not(test))] use durs_common_tools::fatal_error; use durs_conf::DuRsConf; @@ -77,6 +78,15 @@ pub fn start_web_server( HttpServer::new(move || { App::new() .data(global_context.clone()) + .wrap( + Cors::new() + .allowed_headers(vec![ + header::AUTHORIZATION, + header::ACCEPT, + header::ACCESS_CONTROL_ALLOW_ORIGIN, + ]) + .allowed_methods(vec!["GET", "POST", "OPTIONS"]), + ) .wrap(middleware::Logger::default()) .service(web::resource("/graphql").route(web::post().to_async(graphql))) .service(web::resource("/graphiql").route(web::get().to(graphiql)))