commit a523cbbf0efaa493cc159045cd64ebb6ee9d85ff
parent b2e56c14e741dd99736eb7cf6d5328fb759f8816
Author: Antoine A <>
Date: Thu, 16 Jul 2026 03:28:04 +0200
common: add CORS rules
Diffstat:
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/common/taler-api/Cargo.toml b/common/taler-api/Cargo.toml
@@ -15,6 +15,7 @@ listenfd = "1.0.0"
dashmap = "6.1"
http-body-util.workspace = true
zlib-rs = "0.6.3"
+tower-http = { version = "0.7", features = ["cors"] }
tokio = { workspace = true, features = ["signal"] }
rand.workspace = true
serde.workspace = true
diff --git a/common/taler-api/src/api.rs b/common/taler-api/src/api.rs
@@ -36,6 +36,7 @@ use taler_common::{
types::amount::{Amount, Currency},
};
use tokio::signal;
+use tower_http::cors::{Any, CorsLayer};
use tracing::{Level, debug, info};
use wire::WireGateway;
@@ -116,6 +117,12 @@ impl TalerRouter for Router {
fn finalize(self) -> Router {
self.method_not_allowed_fallback(async || failure_code(ErrorCode::GENERIC_METHOD_INVALID))
.fallback(async || failure_code(ErrorCode::GENERIC_ENDPOINT_UNKNOWN))
+ .layer(
+ CorsLayer::new()
+ .allow_origin(Any)
+ .allow_methods(Any)
+ .allow_headers(Any),
+ )
.layer(middleware::from_fn(logger_middleware))
}