diff --git a/examples/cors/src/main.rs b/examples/cors/src/main.rs index 14c4e1b4..28fa05f0 100644 --- a/examples/cors/src/main.rs +++ b/examples/cors/src/main.rs @@ -24,6 +24,10 @@ async fn main() { let app = Router::new().route("/json", get(json)).layer( // see https://docs.rs/tower-http/latest/tower_http/cors/index.html // for more details + // + // pay attention that for some request types like posting content-type: application/json + // it is required to add ".allow_headers(vec![http::header::CONTENT_TYPE])" + // or see this issue https://github.com/tokio-rs/axum/issues/849 CorsLayer::new() .allow_origin(Origin::exact("http://localhost:3000".parse().unwrap())) .allow_methods(vec![Method::GET]),