diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index e53395a..1614e6b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,13 +11,15 @@ use std::{net::SocketAddr, sync::Arc, time::Duration}; use crate::config::CONFIG; use async_graphql::{EmptySubscription, Schema}; use axum::{ - http::{header, Request}, + http::{header, Method, Request}, routing::post, Extension, Router, }; use tokio::net::TcpListener; use tower_http::{ - classify::ServerErrorsFailureClass, sensitive_headers::SetSensitiveHeadersLayer, + classify::ServerErrorsFailureClass, + cors::{Any, CorsLayer}, + sensitive_headers::SetSensitiveHeadersLayer, trace::TraceLayer, }; @@ -63,6 +65,12 @@ async fn create_app() -> Router { }, ), ) + .layer( + CorsLayer::new() + .allow_methods([Method::OPTIONS, Method::GET, Method::POST]) + .allow_headers(vec![header::CONTENT_TYPE, header::AUTHORIZATION]) + .allow_origin(Any), + ) .layer(Extension(state)) } |