Skip to content
Snippets Groups Projects
Commit 97bd259e authored by jm's avatar jm
Browse files

[feat] gva: add cors configuration

parent 2ebb6366
No related branches found
No related tags found
1 merge request!241[feat] gva: add cors configuration
...@@ -31,6 +31,17 @@ dependencies = [ ...@@ -31,6 +31,17 @@ dependencies = [
"trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "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]] [[package]]
name = "actix-http" name = "actix-http"
version = "0.2.11" version = "0.2.11"
...@@ -667,6 +678,17 @@ dependencies = [ ...@@ -667,6 +678,17 @@ dependencies = [
"syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "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]] [[package]]
name = "derive_more" name = "derive_more"
version = "0.15.0" version = "0.15.0"
...@@ -1048,6 +1070,7 @@ dependencies = [ ...@@ -1048,6 +1070,7 @@ dependencies = [
name = "durs-gva" name = "durs-gva"
version = "0.1.0" version = "0.1.0"
dependencies = [ 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)", "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)", "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)", "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
...@@ -3348,6 +3371,7 @@ dependencies = [ ...@@ -3348,6 +3371,7 @@ dependencies = [
[metadata] [metadata]
"checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453" "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-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-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-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" "checksum actix-rt 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "88c9da1d06603d82ec2b6690fc5b80eb626cd2d6b573f3d9a71d5252e06d098e"
...@@ -3410,6 +3434,7 @@ dependencies = [ ...@@ -3410,6 +3434,7 @@ dependencies = [
"checksum crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4" "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 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 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 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 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" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
......
...@@ -11,6 +11,7 @@ path = "src/lib.rs" ...@@ -11,6 +11,7 @@ path = "src/lib.rs"
[dependencies] [dependencies]
actix-web = "1.0.9" actix-web = "1.0.9"
actix-cors = "0.1.0"
dubp-block-doc = { path = "../../dubp/block-doc"} #, version = "0.1.0" } dubp-block-doc = { path = "../../dubp/block-doc"} #, version = "0.1.0" }
dup-crypto = { path = "../../crypto" } dup-crypto = { path = "../../crypto" }
durs-bc-db-reader = { path = "../../modules-lib/bc-db-reader", features = ["client-indexer"] } durs-bc-db-reader = { path = "../../modules-lib/bc-db-reader", features = ["client-indexer"] }
......
...@@ -18,7 +18,8 @@ use crate::context::GlobalContext; ...@@ -18,7 +18,8 @@ use crate::context::GlobalContext;
use crate::db::BcDbRo; use crate::db::BcDbRo;
use crate::graphql::graphql; use crate::graphql::graphql;
use crate::schema::create_schema; 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))] #[cfg(not(test))]
use durs_common_tools::fatal_error; use durs_common_tools::fatal_error;
use durs_conf::DuRsConf; use durs_conf::DuRsConf;
...@@ -77,6 +78,15 @@ pub fn start_web_server( ...@@ -77,6 +78,15 @@ pub fn start_web_server(
HttpServer::new(move || { HttpServer::new(move || {
App::new() App::new()
.data(global_context.clone()) .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()) .wrap(middleware::Logger::default())
.service(web::resource("/graphql").route(web::post().to_async(graphql))) .service(web::resource("/graphql").route(web::post().to_async(graphql)))
.service(web::resource("/graphiql").route(web::get().to(graphiql))) .service(web::resource("/graphiql").route(web::get().to(graphiql)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment