diff options
Diffstat (limited to 'server/src')
| -rw-r--r-- | server/src/main.rs | 22 | 
1 files changed, 19 insertions, 3 deletions
diff --git a/server/src/main.rs b/server/src/main.rs index 4a211fd..7da56d6 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -5,12 +5,16 @@ mod models;  mod routes;  use axum::{ -    http::{header, Request}, +    http::{header, Method, Request},      Router,  };  use std::time::Duration; -use tower_http::sensitive_headers::SetSensitiveHeadersLayer; -use tower_http::{classify::ServerErrorsFailureClass, trace::TraceLayer}; +use tower_http::{ +    classify::ServerErrorsFailureClass, +    cors::{Any, CorsLayer}, +    sensitive_headers::SetSensitiveHeadersLayer, +    trace::TraceLayer, +};  use tracing::Span;  /// Main application, called by the execution of the software @@ -57,4 +61,16 @@ async fn create_app() -> Router {                      },                  ),          ) +        .layer( +            CorsLayer::new() +                .allow_methods([ +                    Method::OPTIONS, +                    Method::GET, +                    Method::POST, +                    Method::PUT, +                    Method::DELETE, +                ]) +                .allow_headers(vec![header::CONTENT_TYPE, header::AUTHORIZATION]) +                .allow_origin(Any), +        )  }  |