Skip to content

Commit

Permalink
fix for CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
hamrt authored and berkes committed Jul 17, 2024
1 parent 11d44d1 commit 9e692be
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 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 agent_api_rest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ axum-macros = "0.3"
http-api-problem = "0.57"
hyper = { version = "0.14", features = ["full"] }
tower-http = { version = "0.3.4", features = ["cors"] }
http = "0.2"
serde.workspace = true
serde_json.workspace = true
tracing.workspace = true
Expand Down
4 changes: 3 additions & 1 deletion agent_api_rest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use axum::{
Router,
};
use tower_http::cors::{Any, CorsLayer};
use http::header::{AUTHORIZATION, ACCEPT, CONTENT_TYPE};
use credential_issuer::{
credential::credential,
token::token,
Expand All @@ -24,7 +25,8 @@ pub const AGGREGATE_ID: &str = "agg-id-F39A0C";

pub fn app(state: ApplicationState<IssuanceData, IssuanceDataView>) -> Router {
let cors = CorsLayer::new()
.allow_methods([Method::GET, Method::POST])
.allow_methods([Method::GET, Method::POST, Method::OPTIONS])
.allow_headers([AUTHORIZATION, ACCEPT, CONTENT_TYPE])
.allow_origin(Any);
Router::new()
.route("/v1/credentials", post(credentials))
Expand Down

0 comments on commit 9e692be

Please sign in to comment.